#include <iostream>
using namespace std;
int main(){
int n;
cin >> n;
while (n){
int M;
cin >> M;
long int a[40];
a[0] = 0;
a[1] = 1;
for (int i = 2; i <= M; i++){
//到第n级台阶有两种方法,即在第n-1级处上1级,在第n-2级处上2级
a[i] = a[i - 1] + a[i - 2];
}
cout << a[M] << endl;
n--;
}
return 1;
}
杭电acm2041:递归楼梯
最新推荐文章于 2024-02-25 23:46:06 发布