<PREV Problem:
NEXT>
Solved by 232 users: ...
UserDateAttemptTimeCMSC
greck12 may 2008Ruby100.0387 
bush10 jan 2013Ruby1400.0290 
bush10 jan 2013Ruby1300.0297 
gchebanov02 dec 2010Python700.06103 
shurik07 may 2009Ruby2200.07105 
bush10 jan 2013Ruby600.02110 
Evgenii24 jan 2011C++1400.01115 
bush10 jan 2013Ruby500.02119 
bush10 jan 2013Ruby1200.02120 
MasterYoda16 jul 2009C++600.02121 
MasterYoda16 jul 2009C++500.01122 
shurik10 oct 2008Ruby2000.06122 
shurik10 oct 2008Ruby2100.06122 
gchebanov02 dec 2010Python400.06123 
MasterYoda16 jul 2009C++400.01126 
ethanhunt24 may 2011C600.01133 
ethanhunt24 may 2011C500.01135 
mikelan03 mar 2012C200.01137 
shurik10 oct 2008Ruby1900.05138 
dzhavaharnal07 jul 2016Ruby1100.02142 
N1k1tung11 mar 2009C++800.37144 
Evgenii24 jan 2011C++1200.01148 
ethanhunt24 may 2011C300.01153 
ethanhunt24 may 2011C400.01153 
Evgenii24 jan 2011C++1000.01154 
Languages
C++
149
Java
28
Kylix
17
FPC
15
C
14
Ruby
8
Python
5
Haskell
2
Scheme
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Fibonacci II

Time limit = 1 second(s)

Find F(N) % K (binary operator % stands for residual).

Definition: F(1) = F(2) = 1.   F(n) = F(n-1) + F(n-2).

Input. Two lines with two numbers — N and K. 1 ≤ N, K ≤ 2 000 000 000.

Output One line with F(N) % K .

Input#1
9
3
Output#1
1
Input#2
66
66
Output#2
52

Author:
Nikolay Strakhov
16 May 2008

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 3.228.10.17