题意:。。。

析:由于能最后一个是特殊的,所以前n-1个都是不变的,只是减少了最后一个盘子的次数,所以根据上一个题的结论 答案就是dp[n-1] + 2。

上一题链接:http://www.cnblogs.com/dwtfukgv/p/6283879.html

代码如下;

#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[maxn]; void init(){
dp[1] = 2;
for(int i = 2; i < 21; ++i) dp[i] = dp[i-1] * 3LL + 2LL;
} int main(){
init();
int T; cin >> T;
while(T--){
cin >> n;
cout << dp[n-1] + 2LL << endl;
}
return 0;
}

最新文章

  1. linux iptables常用命令之配置生产环境iptables及优化
  2. thinkphp怎么设置输入网址直接进入首页
  3. 【转】Android选项卡置底的方法
  4. /proc/interrupts 统计2.6.38.8与3.10.25差异
  5. 复杂领域的Cynefin模型和Stacey模型
  6. 《OD学算法》排序
  7. js之json
  8. 部署WEB应用程序
  9. CentOS 下 Codeblocks 的 安装 + 汉化 以及 基本使用介绍
  10. 安装sinopia-ldap
  11. 跨域的小小总结:js跨域及跨域的几种解决方法
  12. python google play
  13. jQuery 基本实现功能模板
  14. (转)Android 判断用户2G/3G/4G移动数据网络
  15. MSSQL常用函数大全
  16. RPC框架——简单高效hessian的使用方式
  17. log4go 的 Bug Fix 及 增强
  18. jQuery DOM对象区别与联系
  19. 安卓Html标签,创意工具类
  20. android bitmap压缩几种色彩详解

热门文章

  1. SolidEdge 装配体中如何快速的搞定一个面上所有螺丝 如何在装配体上进行阵列
  2. Tomcat部署项目时出错java.lang.IllegalStateException: ContainerBase.addChild: start:org.apache.catalina.Life
  3. vue - 前置工作
  4. mysqldbcopy 数据库复制工具
  5. 机器学习技法总结(六)Decision Tree Hypothesis
  6. 【转载】Http协议与TCP协议简单理解
  7. 高速查询hive数据仓库表中的总条数
  8. openstack 中国联盟公开课參会总结
  9. 【POJ 1716】Integer Intervals(差分约束系统)
  10. 怎样在QML中利用Sprite来做我们须要的动画