import java.util.Scanner; public class Main{ public static void main(String[] args) { int maxn=1000000+5; int mod=10007; int[] Fibonacci=new int[maxn]; Fibonacci[1]=1; Fibonacci[2]=1; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=3;i<=n;i++) { Fibonacci[i]=Fibonacci[i-1]+Fibonacci[i-2]; Fibonacci[i]%=mod; } System.out.println(Fibonacci[n]); sc.close(); } }
import java.util.Scanner;
public class Main{public static void main(String[] args) {int maxn=1000000+5;int mod=10007;int[] Fibonacci=new int[maxn];Fibonacci[1]=1;Fibonacci[2]=1;Scanner sc=new Scanner(System.in);int n=sc.nextInt();for(int i=3;i<=n;i++){Fibonacci[i]=Fibonacci[i-1]+Fibonacci[i-2];Fibonacci[i]%=mod;}System.out.println(Fibonacci[n]);sc.close();}}
原文地址:https://www.cnblogs.com/life-affirming/p/10540603.html
时间: 2024-11-05 15:00:00