Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
|||||
2013-12-10 01:33:46 Vinit Pandey
got AC ... ans for 10^15 is 6 Alex is wrong :/ |
|||||
2012-12-15 03:56:27 $!:D
plzz help... getting WA dont know why... solution id. 8265346 Last edit: 2012-12-15 04:08:24 |
|||||
2012-06-01 04:21:41 Pandian
@tazo : You don't need f[1000000001] .. and remember f[1]=0,f[2]=1. .. |
|||||
2012-05-16 06:50:58 Himanshu
Is the question unpublished ?? |
|||||
2012-05-13 07:48:51 Divanshu
@tazo - Here they are taking f(1) as 0 and you must be getting that answer with f(1) as 1.. mind that! |
|||||
2012-04-25 23:59:52 Shizuo Heiwajima
@Alex You Wrong Guy's... |
|||||
2012-04-19 22:57:42 *tazo*
can you please check my solution? ID: 6875531 I think 60,61,62,63 is 0,1,1,2 no? Last edit: 2012-04-19 22:59:27 |
|||||
2012-04-16 21:45:59 Alex Anderson
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. http://www.spoj.pl/problems/FIBOSUM/ I know there was one that just straight up asked for the Nth fibonacci number mod 10^9 + 6, where N is up to 10^108 Last edit: 2012-04-18 12:04:14 |
|||||
2012-04-15 08:03:17 god_father
some test cases with AC sol.for n=60,61,62,63 output should be 1,0,1,1.. |