【注意】一定要考虑上限是否溢出int,这题改成long long int就对了
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
static long long int s[50];
long long int step(int n)
{
if(n==1) return 1;
if(n==2) return 2;
if(s[n]==0)
s[n]=step(n-1)+step(n-2);
return s[n];
}
int main()
{
int n;
while(cin>>n)
{
cout<<step(n)<<endl;
}
return 0;
}