input | output |
---|---|
3 |
4 |
#include <algorithm> #include <map> #include <cstring> #include <cmath> #include <iostream> using namespace std; #define lson l , m , rt << 1 #define rson m + 1 , r , rt << 1 | 1 #define LL __int64 typedef long long ll; #define PI 3.1415926 ll dp[46]; int main() { int i; dp[1]=2; dp[2]=2; dp[3]=4; for(i=4;i<=45;i++) dp[i]=dp[i-1]+dp[i-2]; int n; while(cin>>n) cout<<dp[n]<<endl; return 0; }
原文地址:http://blog.csdn.net/sky_miange/article/details/45314989