题意:。。。

析:每次都是有三种放法,1,2,3,根柱子,所以就是3^n次方。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#define debug() puts("++++");
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 40 + 5;
const int mod = 2000;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
LL dp[64]; void init(){
dp[1] = 3;
for(int i = 2; i < 64; ++i)
dp[i] = dp[i-1] * 3LL;
} int main(){
init();
int T; cin >> T;
while(T-- && cin >> n) cout << dp[n] << endl;
return 0;
}

HDU 1996 汉诺塔VI (排列组合)的更多相关文章

  1. HDU 1996汉诺塔VI

    题目: n个盘子的汉诺塔问题的最少移动次数是2^n-1,即在移动过程中会产生2^n个系列.由于 发生错移产生的系列就增加了,这种错误是放错了柱子,并不会把大盘放到小盘上,即各柱 子从下往上的大小仍保持 ...

  2. HDUOJ---1996汉诺塔VI

    汉诺塔VI Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  3. 汉诺塔系列问题: 汉诺塔II、汉诺塔III、汉诺塔IV、汉诺塔V、汉诺塔VI

    汉诺塔 汉诺塔II hdu1207: 先说汉若塔I(经典汉若塔问题),有三塔.A塔从小到大从上至下放有N个盘子.如今要搬到目标C上. 规则小的必需放在大的上面,每次搬一个.求最小步数. 这个问题简单, ...

  4. HDU 1207 汉诺塔II (找规律,递推)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1207 汉诺塔II Time Limit: 2000/1000 MS (Java/Others)     ...

  5. HDU 2077 汉诺塔IV (递推)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2077 还记得汉诺塔III吗?他的规则是这样的:不允许直接从最左(右)边移到最右(左)边(每次移动一定是 ...

  6. HDU 2064 汉诺塔III (递推)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2064 约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下.由小到 ...

  7. hdu 1207 汉诺塔II (DP+递推)

    汉诺塔II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. HDU 2064 汉诺塔III

    汉诺塔III Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  9. HDU 2064 汉诺塔III(递归)

    题目链接 Problem Description 约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下.由小到大顺序串着由64个圆盘构成的塔.目的是将最左边杆上的盘 ...

随机推荐

  1. gdb源码安装过程中的问题:no termcap library found

    gdb使用源码安装的时候遇到错误:no termcap library found ./configure -->  make --> make install 解决办法,下载termca ...

  2. jmeter Plugins Manager插件管理

    在 https://jmeter-plugins.org/downloads/all/ 下载插件,放到lib/ext Download plugins-manager.jar and put it i ...

  3. python实现QQ机器人(自己主动登录,获取群消息,发送群消息)

    一次偶然的机会我看见了一个群里的一个QQ号总是依据你所发的消息自己主动回复,当时非常感觉到奇妙.我知道能够模拟登录站点,没想到居然也能模拟登录QQ,首先自己想到的就是怎样实现模拟登录PC端的QQ, 開 ...

  4. react 使用 moment 进行 日期格式化

    在react中使用得先导入: import moment from 'moment'; 调用: npm install moment var moment = require('moment'); m ...

  5. 数组遍历 map()、forEach() 及 字符串切割 split() / 字符串截取 slice()、substring()、substr()

    JS数组遍历的几种方式 JS数组遍历,基本就是for,forin,foreach,forof,map等等一些方法,以下介绍几种本文分析用到的数组遍历方式以及进行性能分析对比 第一种:普通for循环 代 ...

  6. swift,demo,ios8

    swift交流群:342581988,欢迎增加. 刚刚写的小 demo.搞得还是不是太好.请大家拍砖! 能够直接复制执行 import UIKit class ViewController: UIVi ...

  7. viewcontroller生命周期知识要点

    一 viewcontroller执行方法的主要顺序为: init—>loadView—>viewDidLoad—>viewWillApper—>viewDidApper—> ...

  8. CSS属性中Display与Visibility的不同

    大多数人很容易将CSS属性display和visibility混淆,它们看似没有什么不同,其实它们的差别却是很大的.visibility属性用来确定元素是显示还是隐藏,这用visibility=&qu ...

  9. HDU 2601An easy problem-素数的运用,暴力求解

    id=17433" target="_blank" style="color:blue; text-decoration:none">An ea ...

  10. Hdu3785

    <span style="color:#6600cc;">/* G - 寻找大富翁 Time Limit:1000MS Memory Limit:32768KB 64b ...