方法:边加边取余,否则会溢出,long long 也会。
AC代码:
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <ctime>
using namespace std;
const int maxn = 1000000+0;
long long int list[maxn];
void MakeList()
{
int i = 0;
list[0]= 7, list[1] = 11;
for (i = 2; i < maxn; i++)
list[i] = (list[i-2] + list[i-1]) % 3;
}
int main()
{
#ifdef Local
freopen("a.in", "r", stdin);
#endif
int n = 0;
MakeList();
while(cin >> n)
{
if (0 == list[n] % 3)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return 0;
}