题目:https://www.nowcoder.com/pat/2/problem/251
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 const int maxn = 92; 5 long long f[maxn]; 6 void db(){ 7 f[1] = 1; 8 f[2] = 2; 9 for (int i = 3; i < maxn; i++){ 10 f[i] = f[i - 1] + f[i - 2]; 11 } 12 } 13 14 int main(){ 15 db(); 16 int n; 17 while (cin >> n){ 18 cout << f[n] << endl; 19 } 20 //system("pause"); 21 return 0; 22 }