博客
关于我
FZU 1147 Tiling
阅读量:130 次
发布时间:2019-02-27

本文共 1932 字,大约阅读时间需要 6 分钟。

 

Tiling

Time Limit:1s Memory limit:32M
Accepted Submit:197 Total Submit:496

In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles?

Here is a sample tiling of a 2x17 rectangle.

 

Input is a sequence of lines, each line containing an integer number 0 <= n <= 250. For each line of input, output one integer number in a separate line giving the number of possible tilings of a 2xn rectangle.

Sample input

2812

Output for the sample input

31712731

Original: Albert 2001

 

解题:

       瓷砖有2x1 和2x2的,就如图所示的那样的,可以随便组合而成。要问我们2xn矩形里面铺瓷砖,一共有多少种铺法,0<=n<=250。当n为0的时候,方法只有1种那就是不铺(切记),下面看下其他的。

tiles[1]=1种;
tiles[2]=3种;
tiles[3]=5种;
tiles[4]=11种;

则tiles[n]=tiles[n-1]+tiles[n-2]*2;

每次增加一个,我们在上一个的基础上再考虑额外的情况,要用到大数加法和乘法。

转载地址:http://wcid.baihongyu.com/

你可能感兴趣的文章
MySQL 数据库的高可用性分析
查看>>
MySQL 数据库设计总结
查看>>
Mysql 数据库重置ID排序
查看>>
Mysql 数据类型一日期
查看>>
MySQL 数据类型和属性
查看>>
mysql 敲错命令 想取消怎么办?
查看>>
Mysql 整形列的字节与存储范围
查看>>
mysql 断电数据损坏,无法启动
查看>>
MySQL 日期时间类型的选择
查看>>
Mysql 时间操作(当天,昨天,7天,30天,半年,全年,季度)
查看>>
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>