杭电ACM2041楼梯问题
#include<iostream>using namespace std;int main(){ int n,a; int m[45]={0,1,1}; cin>>n; while(n--) { for(int i=3;i<=40;i++) m[i]=m[i-1]+m[i-2]; cin>>a; cout<<m[a]<<endl; } return 0;}#include<stdio.h>int main(){int n, m[50] = {0, 1, 1},i,a; for(i=3;i<=40;i++) m[i]=m[i-1]+m[i-2]; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&a); printf("%d\n",m[a]); }return 0;}