POWERPHI - Power of Phi(medium)

no tags 

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

hide comments
Marty: 2013-08-26 21:08:44

try fibtwist first

Last edit: 2013-08-26 21:10:08
|| तपस् ||: 2013-08-20 17:21:48

plzz anyone provide some hint ..
thanks.:)

[Lakshman]: 2013-06-01 20:45:12

Finally Done....Good problem!!!!

Utkarsh Shahdeo: 2013-05-24 07:27:41

Excellent problem man!! And seriously, non-negative integral power of phi is also very "special" :)!!

Ouditchya Sinha: 2013-05-23 17:43:37

Nice Problem. Learnt something new today. :)

Arika Saputro: 2013-05-18 05:59:10

nice prob ;D

Arika Saputro: 2013-04-04 09:21:14

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

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