62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.*;
public class Demo01
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int c=0;
int a=0;
int b=1;
if(n==1)
{
c=1;
}else if(n>1&&n<1000000)
{
for(int i=0;i<=(n-2);i++)
{
c=a+b;
a=b;
b=c;
}
}
System.out.println(c%10007);
}
}
import java.util.Scanner;
public class My09
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt() ;
int[] a = new int[num+2] ;
a[1] = a[2] = 1;
if (num == 1) {
a[num] = 1 ;
}else if (num == 2) {
a[num] = 1 ;
}else {
for (int i = 3; i <= num; i++)
{
a[i] = (a[i - 1] + a[i - 2]) % 10007;
}
}
System.out.println(a[num]);
}
}