hdu2047

/*
  Description:
    HDU__ACM 2047 阿牛的EOF牛肉串
   
http://acm.hdu.edu.cn/showproblem.php?pid=2047
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>

using namespace std;

long long save[55];

long long f(int n)
{
   if(save[n])
     return save[n];
      
   if(n == 1)
     save[n] = 3;
    else if(n == 2)
      save[n] = 8;
    else save[n] = 2*( f(n-1) + f(n-2) );   
    return save[n];
}
int main()
{
  int n;
  while(scanf("%d", &n) != EOF){
     memset(save, 0, sizeof(save));
     cout<<f(n)<<endl;
  } 
  ////system("pause");
  return 0;
}

你可能感兴趣的:(C++,职场,include,iostream,休闲)