求一道简单ACM但是当数n非常大但不超出题目范围时会出错,求解决方法
Problem DescriptionThere are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
Input
Input an integer n. (n < 1,000,000).
Output
Print the word "yes" if 3 divide evenly into F(n).
Print the word "no" if not.
Sample Input
5
Sample Output
no
Sample Input
2
Sample Output
yes
我的代码:
#include<stdio.h>
int main()
{
int a[100]={7,11},n,i;
scanf("%d",&n);
for(i=2;i<100;i++)
a[i]=a[i-1]+a[i-2];
if(a[n]%3==0)
printf("yes");
else
printf("no");
return 0;
}