博客
关于我
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 的 varchar 水真的太深了!
查看>>
mysql 的GROUP_CONCAT函数的使用(group_by 如何显示分组之前的数据)
查看>>
MySQL 的instr函数
查看>>
MySQL 的mysql_secure_installation安全脚本执行过程介绍
查看>>
MySQL 的Rename Table语句
查看>>
MySQL 的全局锁、表锁和行锁
查看>>
mysql 的存储引擎介绍
查看>>
MySQL 的存储引擎有哪些?为什么常用InnoDB?
查看>>
Mysql 知识回顾总结-索引
查看>>
Mysql 笔记
查看>>
MySQL 精选 60 道面试题(含答案)
查看>>
mysql 索引
查看>>
MySQL 索引失效的 15 种场景!
查看>>
MySQL 索引深入解析及优化策略
查看>>
MySQL 索引的面试题总结
查看>>
mysql 索引类型以及创建
查看>>
MySQL 索引连环问题,你能答对几个?
查看>>
Mysql 索引问题集锦
查看>>