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. JAVA学习第四十七课 — IO流(一):文件的读写

    输入流和输出流相对于内存 将外部设备的数据读取到内存中:输入 将内存中的数据写入外部设备中:输出 IO流经常使用基类 字节流的抽象基类:InputStream,OutputStream 字符的抽象基类 ...

  2. innodb 页分配

    [root@localhost test]# python /root/soft/py_innodb_page_info.py -v t1.ibdpage offset 00000000, page ...

  3. Java基础知识强化之集合框架笔记34:List练习之集合的嵌套遍历

    1. 需求: 我们班有学生,每一个学生是不是一个对象.所以我们可以使用一个集合表示我们班级的学生.ArrayList<Student> 但是呢,我们旁边是不是还有班级,每个班级是不是也是一 ...

  4. 【Android】广播BrocastReceiver

    1.Android中广播主要分为两种:标准广播和有序广播. 标准广播:完全异步执行.广播发出后,所有的广播接收器几乎在同一刻收到广播事件,没有先后顺序之分. 优点:效率高 缺点:不能被截断 有序广播: ...

  5. Bash函数使用

    #!/bin/bash function Fun_Name() { #function here echo "this is a function" } Fun_Name

  6. MVC4将Controller与views分开

    最近自己在要着手从头做一个项目,自己想把mvc里的view和controller文件分别写在不同的项目里,刚开始在网上找了下,可是不尽理想,最后翻了一下自己以前参加的项目找到了这个做法. 这个需要在G ...

  7. SQL常用的语句和函数

    order by 的数值型灵活使用 select * from table_a where order by decode(函数,'asc',1,'desc',-1)*jsny; 控制试图的访问时间: ...

  8. Activity的几种启动跳转方式

     一.显示调用方法 •Intent intent=new Intent(this,OtherActivity.class); //方法1 •Intent intent2=new Intent(); • ...

  9. .net excel利用NPOI导入oracle

    1.链接数据库 引用System.Data.OracleClient: //数据库链接字符串   Data Source如:192.168.5.153:1521/orcl string linkStr ...

  10. openURL的使用方法

    openURL的使用方法 openURL的使用方法: view plaincopy to clipboardprint? [[UIApplication sharedApplication] open ...