题目:http://acm.hdu.edu.cn/showproblem.php?pid=1021
判断菲波那切数列是否能被3整除。
#include<iostream> using namespace std; int a[1000005] = { 0 }; int main() { a[0] = 7; a[1] = 11; for (int i = 2; i < 1000005; i++) a[i] = (a[i - 1] + a[i - 2])%3; int n; while (cin >> n) { if (a[n] == 0) cout << "yes\n"; else cout << "no\n"; } return 0; }