杭电2047 题
//阿牛的EOF牛肉串
//思路:递推求解 p[i] = 2*(p[i-2]+p[i-2])
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n==1)
cout<<3<<endl;
else if(n==2)
cout<<8<<endl;
else
{
//注意:使用__int64,否则会超出范围
__int64 *p = new __int64[n];
p[0] = 3;
p[1] = 8;
for(int i=2;i<n;i++)
{
p[i] = 2*(p[i-1]+p[i-2]);
}
printf("%I64d\n",p[n-1]);
delete []p;
}
}
return 0;
}