hdu 2518 Dominoes

Dancing Links~~~

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2518

Dominoes

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 31    Accepted Submission(s): 8


Problem Description
C150-1014-1.jpg

Some day, Tom's father buys him a box of dominoes blocks. In the box, there are 12 different blocks, which are shown above. Tom is a boy who likes to do practice in intelligence, so he spends a whole afternoon in finishing two different rectangles with 3 * 20, which are shown below.

①⑤⑤⑤⑤⑨⑩⑩⑩⑥⑥⑧②②②②②③④④
①⑤⑿⑿⑨⑨⑨⑩⑥⑥⑦⑧⑧⑧⑾⑾③③③④
①①①⑿⑿⑿⑨⑩⑥⑦⑦⑦⑦⑧⑾⑾⑾③④④

①⑧⑦⑦⑦⑦⑥⑩⑨⑿⑿⑿②②②②②③④④
①⑧⑧⑧⑦⑥⑥⑩⑨⑨⑨⑿⑿⑤⑾⑾③③③④
①①①⑧⑥⑥⑩⑩⑩⑨⑤⑤⑤⑤⑾⑾⑾③④④

Tom is sure that these are the only solutions for 3 * 20, and he wants to know the number of solutions for 4 * 15, 5 * 12, ... Can you help him?

You should notice that if a solution will be the same as the other by some flip or rotate, these two solutions should be consider as the same.
 


 

Input
There may be several test cases. Each contains a single line with two positive integers M and N, which means the shape of M * N. Here M * N = 60.
 


 

Output
For each test case, output a line contains the number of solutions.
 


 

Sample Input
1 60 3 20
 


 

Sample Output
0 2

好些天之前写的题了,思路比较简单,不过代码量比较大。。

需要判断出每个图形有几种旋转方式。 建立矩阵,列数数72,60个小方格,外加12个图形限制,每个图形只能用一次。。

因为只有6中情况,所以要先用自己的代码跑出每组例子,然后直接输出结果就ok了。

若是直接把代码提交上去而不进行这样猥琐的处理,估计没有不超时的~~

此题不贴代码了,因为总共就8人过,,保留一些悬念比较好。 ^_^。。

贴一下我总结的旋转规律:

int map1[4][5][2]={0,0,1,0,2,0,2,1,2,2, 0,0,0,1,0,2,1,0,2,0, 0,0,0,1,0,2,1,2,2,2,  0,2,1,2,2,2,2,1,2,0};
    int map4[4][5][2]={0,-1,0,1,1,-1,1,0,1,1 , -1,0,1,0,-1,1,0,1,1,1, 0,-1,0,1,-1,-1,-1,0,-1,1, -1,0,1,0,-1,-1,0,-1,1,-1};
    int map5[8][5][2]={0,0,1,0,1,1,1,2,1,3 ,0,0,0,1,-1,1,-2,1,-3,1 ,0,0,-1,0,-1,-1,-1,-2,-1,-3,  0,0,0,-1,1,-1,2,-1,3,-1
    ,0,0,1,0,1,-1,1,-2,1,-3,  0,0,0,-1,-1,-1,-2,-1,-3,-1, 0,0,-1,0,-1,1,-1,2,-1,3, 0,0,0,1,1,1,2,1,3,1};//
    int map6[4][5][2]={0,0,1,0,1,1,2,1,2,2, 0,2,1,2,1,1,2,0,2,1, 0,0,0,1,1,1,1,2,2,2,  0,1,0,2,1,0,1,1,2,0};
    int map7[8][5][2]={0,0,1,-1,1,0,1,1,1,2,  0,0,0,1,1,1,-1,1,-2,1,  0,0,-1,0,-1,1,-1,-1,-1,-2,  0,0,-1,-1,0,-1,1,-1,2,-1,
    0,0,1,0,1,1,1,-1,1,-2, 0,0,0,-1,1,-1,-1,-1,-2,-1, 0,0,-1,-1,-1,0,-1,1,-1,2,  0,0,-1,1,0,1,1,1,2,1};
    int map8[4][5][2]={0,2,1,2,1,1,1,0,2,0,  0,0,0,1,1,1,2,1,2,2, 0,0,1,0,1,1,1,2,2,2, 0,1,0,2,1,1,2,1,2,0};
    int map9[8][5][2]={0,0,0,-1,-1,0,-1,1,-2,0,  0,0,0,1,-1,0,-2,0,-1,-1, 0,0,-1,0,0,1,0,2,1,1, 0,0,1,0,0,1,0,2,-1,1,
    0,0,0,-1,1,0,2,0,1,1, 0,0,0,1,1,0,2,0,1,-1, 0,0,1,0,0,-1,0,-2,-1,-1, 0,0,-1,0,0,-1,0,-2,1,-1};
    int map10[4][5][2]={0,0,0,-1,0,1,-1,0,-2,0,  0,0,-1,0,1,0,0,1,0,2,  0,0,0,-1,0,1,1,0,2,0, 0,0,-1,0,1,0,0,-1,0,-2};
    int map11[8][5][2]={0,0,0,1,1,-1,1,0,1,1, 0,0,0,-1,1,-1,1,0,1,1, 0,0,-1,0,-1,1,0,1,1,1, 0,0,1,0,1,1,0,1,-1,1,
    0,0,0,1,-1,-1,-1,0,-1,1, 0,0,0,-1,-1,-1,-1,0,-1,1, 0,0,-1,0,-1,-1,0,-1,1,-1, 0,0,1,0,-1,-1,0,-1,1,-1};
    int map12[8][5][2]={0,0,1,0,1,-1,0,1,0,2,  0,0,1,0,1,1,0,-1,0,-2,  0,0,0,1,1,1,-1,0,-2,0, 0,0,0,1,-1,1,1,0,2,0,
    0,0,-1,0,-1,-1,0,1,0,2, 0,0,-1,0,-1,1,0,-1,0,-2, 0,0,0,-1,1,-1,-1,0,-2,0, 0,0,0,-1,-1,-1,1,0,2,0};
 很黄很暴力吧!!  当时提交成功的时候我都很佩服我自己,这么多数竟然没写错一个。。。。

转载于:https://www.cnblogs.com/183zyz/archive/2011/08/17/2143537.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值