/*

汉诺塔VI

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1080    Accepted Submission(s): 761

Problem Description
n个盘子的汉诺塔问题的最少移动次数是2^n-1,即在移动过程中会产生2^n个系列。由于
发生错移产生的系列就增加了,这种错误是放错了柱子,并不会把大盘放到小盘上,即各柱
子从下往上的大小仍保持如下关系 :
n=m+p+q 
a1>a2>...>am
b1>b2>...>bp
c1>c2>...>cq
计算所有会产生的系列总数.
 
Input
包含多组数据,首先输入T,表示有T组数据.每个数据一行,是盘子的数
目N<30.
 
Output
对于每组数据,输出移动过程中所有会产生的系列总数。
 
Sample Input
3
1
3
29
 
Sample Output
3
27
68630377364883

*/

#include<iostream>
#include<cmath>
int main()
{
using namespace std;
unsigned t,n;
unsigned long long result;
cin>>t;
while(t--)
{
cin>>n;
cout<<(unsigned long long)pow(3,n)<<endl;
}
return 0;
}
/*#include <stdio.h>
#include <math.h>
int main()
{
int t,n;
scanf("%d",&t);
while(t-- && scanf("%d",&n))
printf("%I64d\n",(__int64)pow(3.0,n));
return 0;
}*/

ACM1996的更多相关文章

随机推荐

  1. python os.stat() 和 stat模块详解

    stat 系统调用时用来返回相关文件的系统状态信息的. 首先我们看一下stat中有哪些属性: >>> import os >>> print os.stat(&qu ...

  2. 254. Factor Combinations

    题目: Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a ...

  3. Android关于实现EditText中加多行下划线的的一种方法

    1. 重写EditText public class LinedEditText extends EditText { private Paint linePaint; private float m ...

  4. 删除单链表的倒数第k个结点

    策略 直接遍历总数为len,再次遍历第len-k+1个就是答案,但是这样遍历了O(N+k)个,可以在O在更短的时间内找到 图示 参考代码 #include <iostream> using ...

  5. DNS主配置文件的几个选项

    options块中:   listen-on port 监听DNS查询请求的本机IP地址及端口      eg:listen-on port 53 { 192.168.0.78 };监听本机的192. ...

  6. LTDFZ

    开关稳压器

  7. Internet Explorer for Mac the Easy Way: Run IE 7, IE8, & IE9 Free in a Virtual Machine

        From link: http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/ If you’re ...

  8. Jenkins iOS – Git, xcodebuild, TestFlight

    Introduction with Jenkins iOS If you are new to continuous integration for mobile platforms then you ...

  9. Facebook存储技术方案:找出“暖性BLOB”数据

    Facebook公司已经在其近线存储体系当中彻底弃用RAID与复制机制,转而采用分布式擦除编码以隔离其所谓的“暖性BLOB”. 暖性?BLOB?这都是些什么东西?大家别急,马上为您讲解: BLOB—— ...

  10. 前端SPA框架一些看法

    说起前端框架,我个人主张有框架不如无框架,这个观点要先从框架和库的区别说起. 我所理解的库,解决的是代码或是模块级别的复用或者对复杂度的封装问题;而框架,更多的是对模式级别的复用和对程序组织的规范,这 ...