//1021
//思路:求出各个fn,再挨个判断其是否能被3整除.
#include<iostream>
using namespace std;
#define N 1000000
int f[N];
int main()
{
int n;
int i;
f[0] = 1;//%3的结果
f[1] = 2;//也是%3的结果
//注意:如果不直接先%3的话,提交以后就会wrong answer
for ( i = 2; i < N; i++)
{
f[i] = (f[i - 1] + f[i - 2])%3;
}
while (cin>>n)
{
if (f[n]==0)
{
cout << "yes" << endl;
}
else
{
cout << "no" << endl;
}
}
return 0;
}
原文地址:https://www.cnblogs.com/BlueBlue-Sky/p/8531083.html
时间: 2024-10-11 17:59:03