博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj2506——Tiling(递推+大数加)
阅读量:2343 次
发布时间:2019-05-10

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

Description

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

Input is a sequence of lines, each line containing an integer number 0 <= n <= 250.

Output

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

2

8
12
100
200
Sample Output

3

171
2731
845100400152152934331135470251
1071292029505993517027974728227441735014801995855195223534251

给2x1和2x2的地板,求铺成2xn的面积有多少种排列方式

网上找的,都是大神,真的。说什么a[n]=a[n-1]+2*a[n-2],反正我是没看出来

#include
#include
#include
using namespace std;string a[300];string Add(string s1,string s2){ if (s1.length()
=0;i--,j--) { s1[i]=s1[i]+(j>=0?s2[j]-'0':0); if(s1[i]-'0'>=10) { s1[i]=(s1[i]-'0')%10+'0'; if(i) s1[i-1]++; else s1='1'+s1; } } return s1;}int main(){ int i,n; a[0]="1",a[1]="1",a[2]="3"; for (i=3; i<=250; i++) a[i]=Add(Add(a[i-1],a[i-2]),a[i-2]); while (cin>>n) cout<
<

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

你可能感兴趣的文章
解决文件提示: /bin/ksh^M: bad interpreter: bad interpreter:No such file or directory
查看>>
ajaxanywhere jsp 使用
查看>>
jquery的使用
查看>>
如何静态化JSP页面
查看>>
XML 与 Java 技术: 用 Castor 进行数据绑定
查看>>
Python未知领域系列:(附Python学习教程+Python学习路线)Python高级教程之面向对象
查看>>
盘点Python 面向对象编程最容易被忽视的知识点
查看>>
Python:一个可以套路别人的python小程序
查看>>
用Python告诉你:这些年,我们点过的的那些外卖
查看>>
如何美观地打印Python对象?这个标准库可以简单实现
查看>>
写作路上的这些小成绩,铸就了一个不平庸的程序员
查看>>
程序员找工作的个人经验教训以及注意事项
查看>>
2019 编程语言排行榜:Java、Python 龙争虎斗!谁又屹立不倒
查看>>
拥有10年编程经验的你,为什么还一直停留在原地
查看>>
Flask vs Django,Python Web开发用哪个框架更好
查看>>
用Python制作动态二维码,一行代码就做到了
查看>>
Python说:常见的数据分析库有哪些
查看>>
Python教程:Python数据类型之字典
查看>>
Python基础教程:python的数据类型
查看>>
Python学习教程:另辟蹊径,appium抓取app应用数据了解一下
查看>>