博客
关于我
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/

你可能感兴趣的文章
MongoDB可视化客户端管理工具之NoSQLbooster4mongo
查看>>
Mongodb学习总结(1)——常用NoSql数据库比较
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
mongodb定时备份数据库
查看>>
mppt算法详解-ChatGPT4o作答
查看>>
mpvue的使用(一)必要的开发环境
查看>>
MQ 重复消费如何解决?
查看>>
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT介绍及与其他协议的比较
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0008---服务质量
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>
MS COCO数据集介绍
查看>>
MS Edge浏览器“STATUS_INVALID_IMAGE_HASH“兼容性问题
查看>>
ms sql server 2008 sp2更新异常
查看>>
MS SQL查询库、表、列数据结构信息汇总
查看>>
MS UC 2013-0-Prepare Tool
查看>>