A - A
Crawling in process...
Crawling failed
Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64u
Description
有另一种斐波那契数列:F(0)=7,F(1)=11,F(n)=F(n-1)+F(n-2) (n>=2)
Input
输入数据有多行组成,每一行上是一个整数n(n<1000000);
Output
如果F(n)能被3整除,那么打印一行"yes";否则,打印一行"no".
Sample Input
0
1
2
3
4
5
Sample Output
no
no
yes
no
no
no
水题,直接打表过~
AC代码:
#include<iostream>
const int MAX=1000001;
__int32 s[MAX];
using namespace std;
int main()
{
__int32 n,i;
s[0]=7;
s[1]=11;
for(i=2;i<MAX;i++)
{
s[i]=(s[i-1]+s[i-2])%3;
}
while(cin>>n)
{
if(!s[n])
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}