<PREV Problem:
NEXT>
Solved by 232 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

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 190ms

SW soft NIX
ID = 54.158.248.167