POWERPHI - Power of Phi(medium)

Vertu was very impressed by the golden ratio φ=(1+√5)/2 and about it occurring in nature and all that. He now begins to wonder if any non negative integral power of φ is also special. Since he does not like working with decimals, he decided to approximate the positive integral power of φ to its closest integer. Help him by printing the closest integer to φn, given n.

Input

The first line contains T, the number of test cases. T lines follow, each containing one positive integer n.

Output

For each of these integers, print the closest integer to φn. If you think there are two closest possible integers, print either of them. Print the answer modulo (109+7).

Constraints

T <= 100000

0 <= n <= 109

Example

INPUT:
2
1
3

OUTPUT:
2
4

Added by:darkshadows
Date:2013-03-28
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2013-08-26 21:08:44 Marty
try fibtwist first

Last edit: 2013-08-26 21:10:08
2013-08-20 17:21:48 || तपस् ||
plzz anyone provide some hint ..
thanks.:)
2013-06-01 20:45:12 [Lakshman]
Finally Done....Good problem!!!!
2013-05-24 07:27:41 Utkarsh Shahdeo
Excellent problem man!! And seriously, non-negative integral power of phi is also very "special" :)!!
2013-05-23 17:43:37 Ouditchya Sinha
Nice Problem. Learnt something new today. :)
2013-05-18 05:59:10 Arika Saputro
nice prob ;D
2013-04-04 09:21:14 Arika Saputro
can anyone give some testcase?
is it correct if n=10^9 output is ****(author: no spoils) ?

Last edit: 2013-05-08 18:57:29
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.