HDU 1143
2015-07-21 19:35
323 查看
Tri Tiling
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2764 Accepted Submission(s): 1559
Problem Description
In how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle.
Input
Input consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 ≤ n ≤ 30.
Output
For each test case, output one integer number giving the number of possible tilings.
Sample Input
2 8 12 -1
Sample Output
3 153 2131
#include<stdio.h> using namespace std; int n; long long dp[32]; int main() { dp[0] = 1; dp[2] = 3; dp[4] = 11; for(int i = 6; i < 32; i+=2) dp[i] = 3*dp[i-2] + dp[i-2] - dp[i-4]; while(~scanf("%d",&n)) { if(-1 == n) break; printf("%lld\n",dp ); } return 0; }
相关文章推荐
- hdu3076ssworld VS DDD 概率dp
- 语法分器析总结
- Makefile -fPIC 选项
- GIT仓库恢复
- Mac价格对比
- hdu 1717 小数化分数2
- Storm Trident Example 代码阅读笔记
- Mysql数据库笔记
- ACM学习历程—HDU 5289 Assignment(线段树 || RMQ || 单调队列)
- Ubuntu mysql 中文,启动,重启,远程连接相关问题
- 简单文件操作(库函数)
- poj 3254
- windows下安装php5.5的redis扩展
- java定时任务spring+quartz作业调度
- 管道破裂信号处理。
- SAX解析技术
- javascript笔试面试题
- Python日志之Python函数
- 2015年ALPC暑期专题练习I (计算几何) G - Treasure Hunt
- Java基础的一些博客