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