Topic description
The recursive formula for the Fibonacci sequence is: Fn=fn-1+fn-2, which is f1=f2=1.
When n is larger, the FN is also very large, and now we want to know how much of the remainder of FN divided by 10007.
Input Format
The input contains an integer n.
output Format
Output line that contains an integer that represents the remainder of the FN divided by 10007.
Description: In this question, the answer is to require FN divided by 10007 of the remainder, so as long as we can work out the remainder can be, and do not need to calculate the exact value of FN, and then divide the calculated result by 10007 to the remainder, the direct calculation of the remainder is often more simple than the first to calculate the
Sample Input
10
Sample Output
Sample Example Input
Sample Output
7704 Data size and Convention
1 <= n <= 1,000,000.
Import Java.util.Scanner;
public class Main {public
static void Main (string[] args) {
Scanner cin = new Scanner (system.in);
int a = 1, b = 1, ans = 1,c=cin.nextint ();
for (int i = 1; I <= c-2 i++) {
ans = (a + b)% 10007;
A = b;
b = ans;
}
System.out.println (ANS);
}