每计算一个Fi,都对其取余,防止最后其超出int的范围
#include<iostream> using namespace std; int main() { int n; while(cin >> n) { int x = 1; int y = 1; int z; if(n < 3) cout << 1 << endl; else { for(int i = 3; i <= n; i++) { z = x + y; z = z % 10007; x = y; y = z; } cout << z << endl; } } }