题意:。。。

析:每次都是有三种放法,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. fatal error C1189: #error : core.hpp header must be compiled as C++

    两次opencv工程需要设置为C++编译:找了一半天的解决方法. I am building a C application that uses OpenCV. when compiling, I g ...

  2. 【转】 C++ 简单的 Tcp 实现[socket] 客户端与客户端通信

    //  服务器端代码 // Server.cpp : Defines the entry point for the console application.// #include "std ...

  3. Angularjs: call other scope which in iframe

    Angularjs: call other scope which in iframe -------------------------------------------------------- ...

  4. Thinking in React(翻译)

    下面是React官方文档中的Thinking inReact文章的翻译,第一次翻译英文的文章,肯定有非常多不对的地方,还望多多包涵. 原文地址:https://facebook.github.io/r ...

  5. fetch 函数分装

    1.fetch /** * 封装 fetch */ import { hashHistory } from 'react-router'; export default function reques ...

  6. 我的c++server记录----非堵塞下的socket读取操作

    server端的主要的一个操作就是从socket的fd上进行数据读取.也就是我们经经常使用到的read函数. 欢迎关注我的server代码:http://code.taobao.org/p/fastS ...

  7. MAC上Nuclide的安装

    MAC上Nuclide的安装 本文版权归作者全部,如需转载请联系孟祥月 CSDN博客:http://blog.csdn.net/mengxiangyue 独立博客:http://mengxiangyu ...

  8. Flash/Flex获取外部参数

    Part One:Flex程序如何获取html容器传递的URL参数值 我们经常在Flex程序需要用从外部html向swf文件传递参数,(类似 test.html?name=jex&addres ...

  9. 【转载】C# sleep 和wait的区别

    eep和wait都是使线程暂时停止执行的方法,但它们有很大的不同. 1. sleep是线程类Thread 的方法,它是使当前线程暂时睡眠,可以放在任何位置. 而wait,它是使当前线程暂时放弃对象的使 ...

  10. Comparable 和 Comparator的理解

    对Comparable 的解释 Comparable是一个排序接口 此接口给实现类提供了一个排序的方法,此接口有且只有一个方法 public int compareTo(T o); compareTo ...