#include<bits/stdc++.h> using namespace std; typedef long long ll; int main () { int t,i,n; ll ans[35]; ans[1] = 1,ans[2] = 3; while(scanf("%d",&t)==1) { while(t--) { scanf("%d",&n); for(i = 3;i<=n;i++) ans[i] = 2*ans[i-2]+ans[i-1]; printf("%lld\n",ans[n]); } } return 0; }
[题目链接] (http://acm.hdu.edu.cn/showproblem.php?pid=2501)