http://acm.hdu.edu.cn/showproblem.php?pid=1996
递推
View Code
#include <iostream> #include <string> using namespace std; int main() { int t; __int64 dp[30]={0,3}; for(int i=2;i<30;i++) dp[i]=dp[i-1]*3; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); printf("%I64d\n",dp[n]); } return 0; }