hdu 2501
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2501
递推题:dp[i]=dp[i-1]+dp[i-2]*2(i>=3);
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 using namespace std; 3 int dp[40]; 4 5 int main(){ 6 dp[0]=0,dp[1]=1,dp[2]=3; 7 for(int i=3;i<=31;i++){ 8 dp[i]=dp[i-1]+dp[i-2]*2; 9 } 10 int _case; 11 scanf("%d",&_case); 12 while(_case--){ 13 int n; 14 scanf("%d",&n); 15 printf("%d\n",dp[n]); 16 } 17 return 0; 18 }