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

没什么好说的,递推题,大数自己看看吧,方法很多,我用的数组模拟;

 #include <stdio.h>
#include<string.h>
int main()
{
int s[][],i,j,k,a,t;
memset(s,,sizeof(s));
s[][]=;
s[][]=;
s[][]=;
t=;
for(i=; i<; i++)
{
for(j=; j<=t; j++)
s[i][j]=s[i-][j]+*s[i-][j];//这是地推公式
for(k=; k<=t; k++)
if(s[i][k]>)
{
s[i][k+]+=(s[i][k]/);//大数进位
s[i][k]=s[i][k]%;
}
while(s[i][t]>)//大数进位
{
s[i][t+]=s[i][t]/;
s[i][t]=s[i][t]%;
t++;
}
for(t+=; s[i][t]==;t--);
}
while(~scanf("%d",&a))
{
for(i=; s[a][i]==; i--);
for(i=i; i>; i--)
printf("%d",s[a][i]);
printf("\n");
}
return ;
}

Tiling(递推+大数)的更多相关文章

  1. POJ 2506 Tiling (递推 + 大数加法模拟 )

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7965   Accepted: 3866 Descriptio ...

  2. Children’s Queue HDU 1297 递推+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...

  3. ACM学习历程—HDU1041 Computer Transformation(递推 && 大数)

    Description A sequence consisting of one digit, the number 1 is initially written into a computer. A ...

  4. poj 2506 Tiling 递推

    题目链接: http://poj.org/problem?id=2506 题目描述: 有2*1和2*2两种瓷片,问铺成2*n的图形有多少种方法? 解题思路: 利用递推思想,2*n可以由2*(n-1)的 ...

  5. 【hdoj_1865】1sting(递推+大数)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1865 本题的关键是找递推关系式,由题目,可知前几个序列的结果,序列长度为n=1,2,3,4,5的结果分别是 ...

  6. PKU 2506 Tiling(递推+高精度||string应用)

    题目大意:原题链接有2×1和2×2两种规格的地板,现要拼2×n的形状,共有多少种情况,首先要做这道题目要先对递推有一定的了解.解题思路:1.假设我们已经铺好了2×(n-1)的情形,则要铺到2×n则只能 ...

  7. Tiling 简单递推+大数

    Tiling c[0]=1,c[1]=1,c[2]=3;   c[n]=c[n-1]+c[n-2]*2;   0<=n<=250.   大数加法 java  time  :313ms 1 ...

  8. poj 2506 Tiling(递推 大数)

    题目:http://poj.org/problem?id=2506 题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加; 以前做过了的 #include<stdio.h> # ...

  9. POJ2506:Tiling(递推+大数斐波那契)

    http://poj.org/problem?id=2506 #include <iostream> #include <stdio.h> #include <strin ...

随机推荐

  1. HP P2055d激光打印机PCL XL error的解决

    近日,于客户处安装HP P2055d激光打印机(2009年11月份生产的机器),介绍下硬件环境:PC:Dell OptiPlex 360,另有一台富士通DPK 8600E票据打印机,P2055d通过U ...

  2. python装饰实现线程同步

    import threading def tryfinally(finallyf):   u"returns a decorator that adds try/finally behavi ...

  3. Swift 表视图动画教程: Drop-In Cards

    http://www.raywenderlich.com/76024/swift-table-view-animations-tutorial-drop-cards 标准 table view 是一个 ...

  4. 如何自定义UIPickerView中文本的大小和文本靠左或靠右显示?

    需要重写UIPickerView中的 -(UIView*)pickerView:(UIPickerView*)pickerView viewForRow:(NSInteger)row forCompo ...

  5. 十个最好的Java性能故障排除工具

    1.jconsole  是随着JDK 1.5而推出的.这是一个Java监测和管理控制台-JMX兼容的图形工具来监测Java虚拟机.它能够同时监测本地和远程的JVMs.详情可查看:jconsole工具介 ...

  6. css 权威指南笔记(一)

    零零散散接触css将近5年,俨然已经成为一个熟练工.如果不是换份工作,我不知道自己差的那么远:在qunar的转正review中我这种“知其然而不知其所以然” 的状况被标明,我才意识到我已停步不前近两年 ...

  7. mac 下安装安卓模拟器

    mac下的安卓模拟器——bluestacks 下载:http://pan.baidu.com/s/1kVvZyYz 该安卓模拟器除了能网络下载apk,本地还能安装apk,但是与win版不同,安装不是那 ...

  8. TSQL Beginners Challenge 1 - Find the second highest salary for each department

    很久以前准备写的系列文章,后来因为懒一直耽搁着,今天突然决定继续下去,于是有了这篇文章,很基础,但很常用.题目描述依然拷贝.简单来说就是找出个个部门薪水排名第二的人,排名相同的要一起列出来. Intr ...

  9. 344. Reverse String(C++)

    344. Reverse String Write a function that takes a string as input and returns the string reversed. E ...

  10. QWidget QMainWindow QDialog 三者区别

    Qt类是一个提供所需的像全局变量一样的大量不同的标识符的命名空间.通常情况下,你可以忽略这个类.QObject和一些其它类继承了它,所以在这个Qt命名空间中定义的所有标识符通常情况下都可以无限制的使用 ...