Tri Tiling

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

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
 

参考:http://blog.csdn.net/chaoojie/article/details/8860935

当dp[i] 划分成 2 和 i-2 后,再划分成 4和i-4时,4的部分,不能再划分成2 , 2 组合,这样就会和前面的2 和i-2 重复,同样,划分过2 ,i-2 以及 4, i-4 后,再划分 6, i-6时,也不能划分成 2,2,2 以及 2, 4或 4, 2,同理,划分成8, i-8....

把 4, 6, 8.... 看成一整块,就有下图两种情况(正着,倒着)

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int dp[35];
int t;
dp[0]=1;
dp[1]=0;
dp[2]=3;
for(int i=3;i<=30;i++)
{
if(i%2)
{
dp[i]=0;
continue;
}
dp[i]=dp[2]*dp[i-2];
for(int j=i-4;j>=0;j-=2)
dp[i]+=2*dp[j];
}
while(scanf("%d",&t)&&t!=-1)
{
cout<<dp[t]<<endl;
}
return 0;
}

  

HDU_1143_tri tiling的更多相关文章

  1. Texture tiling and swizzling

    Texture tiling and swizzling 原帖地址:http://fgiesen.wordpress.com If you’re working with images in your ...

  2. 图文详解Unity3D中Material的Tiling和Offset是怎么回事

    图文详解Unity3D中Material的Tiling和Offset是怎么回事 Tiling和Offset概述 Tiling表示UV坐标的缩放倍数,Offset表示UV坐标的起始位置. 这样说当然是隔 ...

  3. POJ3420Quad Tiling(矩阵快速幂)

    Quad Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3740 Accepted: 1684 Descripti ...

  4. Tri Tiling[HDU1143]

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  5. Tiling 分类: POJ 2015-06-17 15:15 8人阅读 评论(0) 收藏

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8091   Accepted: 3918 Descriptio ...

  6. Tiling Up Blocks_DP

    Description Michael The Kid receives an interesting game set from his grandparent as his birthday gi ...

  7. I - Tri Tiling

      Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status #in ...

  8. POJ2506——Tiling

    Tiling Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a samp ...

  9. [POJ 3420] Quad Tiling

      Quad Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3495   Accepted: 1539 Des ...

随机推荐

  1. hdu4057 Rescue the Rabbit(AC自己主动机+DP)

    Rescue the Rabbit Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  2. SQL Server 海量数据查询代码优化以及建议

    1.应尽量避免在  where  子句中对字段进行   null  值推断,否则将导致引擎放弃使用索引而进  行全表扫描,如:     select id from t where num is nu ...

  3. MySQL-修改数据(REPLACE)

    MySQL-REPLACE语句 功能介绍:用于向数据库表插入或更新数据. REPLACE语句的工作原理: 如果给定行数据不存在,那么MySQL REPLACE语句会插入新行. 如果给定行数据存在,则R ...

  4. lvm调整分区大小

    1 问题 /home分区占用空间比较大,而/var分区比较小,它们位于同一个磁盘上.该系统安装了lvm. 2 减少/home分区空间 2.1 卸载/home umount /home 2.2 检查文件 ...

  5. Bridge Page

    http://www.zzbaike.com/wiki/%E6%A1%A5%E9%A1%B5 桥页(Bridge Page),又叫“门页”(Doorway/Portal/Jump/Entry Page ...

  6. 安装linux系统-CentOS-6.8-x86_64-minimal.iso

    1: 2: 3:单击[Next]继续安装. 4:安装语言,选择[Chinese(Simplified)(中文(简体))]菜单,单击[Next]继续. 5:系统键盘,选择[美国英语式]菜单,单击[下一步 ...

  7. 计算属性 computed

    计算属性 computed 计算缓存 vs Methods <div id="example"> <p>Original message: "{{ ...

  8. java笔记线程两种方式模拟电影院卖票

    public class SellTicketDemo { public static void main(String[] args) { // 创建三个线程对象 SellTicket st1 = ...

  9. Net框架下-ORM框架LLBLGen的简介(转载)

    Net框架下-ORM框架LLBLGen的简介 http://www.cnblogs.com/huashanlin/archive/2015/02/12/4288522.html 官方网址:http:/ ...

  10. bzoj 1646: [Usaco2007 Open]Catch That Cow 抓住那只牛【bfs】

    满脑子dp简直魔性 模拟题意bfs转移即可 #include<iostream> #include<cstdio> #include<queue> using na ...