#include <iostream> #include <cstring> using namespace std; const int N =100; int dp[N]; int main() { memset(dp,0,sizeof(dp)); dp[0]=dp[1]=1; for(int i=2;i<=N;i++){ dp[i]=dp[i-1]+dp[i-2]; } int n; while(cin>>n){ cout<<dp[n]<<endl; } return 0; }
#include <iostream> #include <cstring> using namespace std; const int N =100; int dp[N]; int main() { memset(dp,0,sizeof(dp)); dp[0]=dp[1]=1; for(int i=2;i<=N;i++){ dp[i]=dp[i-1]+dp[i-2]; } int n; while(cin>>n){ cout<<dp[n]<<endl; } return 0; }