Computing Salary
Practice
1 (1 votes)
Medium
Combinatorics
Linear algebra
Algorithms
Mathematics
Open
Approved
Problem
31% Success 1535 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

King Tle4Ever of Time Limit Exceeded has recently appointed Ram as his new cashier. To get this job Ram has paid 1 SegFault (SegFault is the currency of Time Limit Exceeded). Today is his first day at work and he will get 1 SegFault for his salary. As Tle4Ever thought this is really less so for the coming days he thought of paying Ram a good amount of SegFaults. For the ith day Ram gets twice the SegFaults for (i-1)th, thrice the SegFaults for (i-2)th day and 3i as bonus for working on ith day.

As you can see Ram is getting a huge amount of SegFaults, he wants to calculate how much SegFaults will he get on kth day. As he is busy working for King, he asks you to tell him the SegFaults he will get on kth day. As the no of SegFaults can be large and to save you from outputting random values, I ask you to print ans % 109 + 7.

[Input]
First line of input consists of single integer t denoting number of test cases.
Next t line contains single integer k denoting the kth day.

[Output]
For each test case print single integer containing ans % 109 + 7.

[Constraints]
1<=t<=105
0<=k<=109

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
1 votes
Tags:
MediumLinear AlgebraMatrix ExponentiationBitmaskAlgorithmsMathematicsOpenApproved
Points:30
Tags:
Medium
Points:30
27 votes
Tags:
Graph TheoryLinear AlgebraApprovedMediumAlgorithmsMathematicsOpenMatrix Exponentiation