题解 | #N阶楼梯上楼问题#
N阶楼梯上楼问题
https://www.nowcoder.com/practice/c978e3375b404d598f1808e4f89ac551
#include <cstdio> #include <iostream> #include <string> using namespace std; const int MAX=91; long long Fib[MAX]; int main(){ Fib[0]=0; Fib[1]=1; Fib[2]=2; for(int i=3;i<MAX;i++){ Fib[i]=Fib[i-1]+Fib[i-2]; } int N; while(scanf("%d",&N)!=EOF){ printf("%lld\n",Fib[N]); } return 0; }