题目:https://www.nowcoder.com/questionTerminal/0984adf1f55a4ba18dade28f1ab15003
1 #include2 #include 3 using namespace std; 4 5 const int maxn = 1000000 + 5; 6 int f[maxn]; 7 8 void db(){ 9 f[0] = 7 % 3;10 f[1] = 11 % 3;11 for (int i = 2; i < maxn; i++){12 f[i] = (f[i - 1] + f[i - 2]) % 3;13 }14 }15 16 int main(){17 db();18 int n;19 while (cin >> n){20 if (f[n] == 0){21 cout << "Yes" << endl;22 }23 else{24 cout << "No" << endl;25 }26 }27 // system("pause");28 return 0;29 }