Given a k degree polynomial P(x)=∑i=0kaixi (0≤ai≤7) and f(n)=“number of such polynomial so that P(2)=n", find ∑i=0mf(i) for a given number m.
I found this problem in an online contest. But it was very tough for me to solve. Luckily I found a solution pattern for this problem generating solution for some small test cases. I found that:
f(n)=⌊4⌊2n+4⌋2⌋
But still, I can't find ∑i=0mf(i). So please help me out.
Input
The first line contains a single integer t (1≤t≤105) number of test cases. On next line there are t numbers, mi(0≤m≤1018) meaning that in case i you should solve for number mi.
Output
For each test case i, print the answer modulo 109+7 on separate lines.
Sample
Input
Output
4
1 2 3 4
2
4
6
10
for the second test case :
$f(0)=1$ because there is only one polynomial for which $P(2)=0$ and the polynomial is $P(x)=0\times x^0$
$f(1)=1$ because there is only one polynomial for which $P(2)=1$ and the polynomial is $P(x)=1\times x^0$
$f(2)=2$ because there is two such polynomial for which $P(2)=2$ and the polynomials are $P(x)=2\times x^0$ and $P(x)=0\times x^0+1\times x^1$
Hence $\sum_{i=0}^{2}{f(i)}=1+1+2=\boxed{4}$
Here ∑i=jkf(i) means f(j)+f(j+1)+f(j+2)+...+f(k−1)+f(k). ⌊x⌋ means “largest integer which is smaller than or equal to x".