题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2077
代码:
#include <iostream>
#include<cstdio>
using namespace std;
int f[25],rl[25],s[25];
void hannuo()
{
f[1]=2;
int cc=2;
for(int i=2;i<25;i++)
{
f[i]=f[i-1]+cc;
cc=cc*3;
}
}
int main()
{
hannuo();
int n;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",f[n]);
}
return 0;
}