TSHOW2 - Fibonacci brain
Ravi is a student who loves Fibonacci numbers. He used to think of Fibonacci numbers all the time. Suddenly he asked his friend Rama whether he can find Nth Fibonacci number. Rama said 'No'. Ravi started laughing. Ravi then asked Rama whether he can at least find the last digit of Nth Fibonacci number. Thinking for a while, Rama said 'Yes'. Help Rama finding the last digit of Nth Fibonacci number. Note : The series starts from 0 (0, 1, 1, 2, 3, ...)
Input
First line consists of an integer t (t<=1000) denoting the number of test cases that follow.
The following t lines consist of an integer N (1<=N<=10^15).
Output
Output t lines consisting of the last digit of Nth Fibonacci number.
Example
Input: 3
1
2
5
Output: 0
1
3
hide comments
Vinit Pandey:
2013-12-10 01:33:46
got AC ... ans for 10^15 is 6
|
|
$!:D:
2012-12-15 03:56:27
plzz help... getting WA dont know why...
|
|
Pandian:
2012-06-01 04:21:41
@tazo : You don't need f[1000000001] .. and remember f[1]=0,f[2]=1. .. |
|
Himanshu:
2012-05-16 06:50:58
Is the question unpublished ?? |
|
Divanshu:
2012-05-13 07:48:51
@tazo - Here they are taking f(1) as 0 and you must be getting that answer with f(1) as 1.. mind that! |
|
Shizuo Heiwajima:
2012-04-25 23:59:52
@Alex You Wrong Guy's... |
|
*tazo*:
2012-04-19 22:57:42
can you please check my solution? ID: 6875531
|
|
Alex Anderson:
2012-04-16 21:45:59
While it is nice that the purpose of this problem is probably to analyze the period of Fibonacci numbers mod 10, there are already many problems about quickly calculating large Fibonacci numbers. I'll link to some.
|
|
god_father:
2012-04-15 08:03:17
some test cases with AC sol.for n=60,61,62,63 output should be 1,0,1,1..
|
Added by: | Pandian |
Date: | 2012-04-12 |
Time limit: | 0.100s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own problem |