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