超级楼梯
#include<iostream> using namespace std; int a[44]; int main(){ a[1] = 0, a[2] = 1, a[3] = 2; for(int i=4; i<=40; i++) a[i] = a[i-1] + a[i-2]; int n; cin>>n; while(n--){ int m; cin>>m; cout<<a[m]<<endl; } return 0; }
超级楼梯
#include<iostream> using namespace std; int a[44]; int main(){ a[1] = 0, a[2] = 1, a[3] = 2; for(int i=4; i<=40; i++) a[i] = a[i-1] + a[i-2]; int n; cin>>n; while(n--){ int m; cin>>m; cout<<a[m]<<endl; } return 0; }