Alice and her sequence
Practice
2 (4 votes)
Ready
Mathematics
Algorithms
Approved
Easy Medium
Problem
18% Success 1185 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Alice is very fond of Sequences. But she got stuck in a problem. She wants to generate sequences of length N , consisting only of numbers \(1,2,3\) In any sequence each number occurs at least once.

So, she wants your help now to compute this. She has been given N , the length of the sequences she needs to generate. You need to help her, and find out how many such sequences exist. Can you do it ?

The number is so large so you need to compute answer modulo \(1000000007\) .

Input Format :

The first line contains a single integer T denoting the number of test cases. Each of the next T lines contains a single integer N, denoting the parameter of the \(i^{th}\) test.

Output Format :

You have to print the number of sequences of length N that consists of at least one occurence of each of 1, 2 and 3. As the answer can be rather large, print it modulo \(10^9+7\).

Constraints

\( 1 \le T \le 100 \)

\( 1 \le N \le 10^6 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
173 votes
Tags:
Binary search algorithmHiringRecursionBrute-force searchEasy-MediumReadyApprovedBacktracking
Points:20
95 votes
Tags:
EasyImplementation
Points:20
41 votes
Tags:
Ad-HocEasyImplementation