Java代码:
1 import java.util.Scanner; 2 3 @SuppressWarnings("all") 4 public class Main { 5 public static void main(String[] args) { 6 Scanner scanner = new Scanner(System.in); 7 int num = scanner.nextInt(); 8 int large = 10007; 9 int[] arr = new int[1000000]; 10 arr[0]=arr[1]=1; 11 for (int i = 2; i <= num; i++) { 12 arr[i]=(arr[i-1]+arr[i-2])%large; 13 } 14 System.out.println(arr[num-1]); 15 } 16 }