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. Android 颜色渲染(四) BitmapShader位图渲染

    版权声明:本文为博主原创文章,未经博主允许不得转载. Android 颜色处理(四) BitmapShader位图渲染 public   BitmapShader(Bitmap bitmap,Shad ...

  2. java获取计算机硬件参数

    public class HardWareUtils { /**   *   * 获取主板序列号   *   *   *   * @return   */ public static String g ...

  3. 转换字符串格式,可用于sql in

    /// <summary> /// 转换字符串格式,可用于sql in /// </summary> /// <param name="lst"> ...

  4. IIS7.5 asp+access数据库连接失败处理 64位系统

    IIS7.5 asp+access数据库连接失败处理(SRV 2008R2 x64/win7 x64) IIS7.5不支持oledb4.0驱动?把IIS运行模式设置成32位就可以了,微软没有支持出64 ...

  5. Css3 常见鼠标滑过效果集合

    1.演示地址: http://yaochuxia.github.io/hover/#

  6. Android EditText自动弹出输入法焦点

    http://mobile.51cto.com/aprogram-403138.htm 1. 看一个manifest中Activity的配置,如果这个页面有EditText,并且我们想要进入这个页面的 ...

  7. 在使用Kettle的集群排序中 Carte的设定——(基于Windows)

    本片文章主要是关于使用Kettle的UI界面: Spoon来实现基于集群的对数据库中的数据表数据进行排序的试验. 以及在实验过程中所要开启的Carte服务的一些配置文件的设置, 还有基于Windows ...

  8. 用PHP实现一个高效安全的ftp服务器(一)

    摘要: 本文主要阐述使用PHP的swoole扩展实现ftp服务器,同时扩展ftp服务器个性化功能和安全性.真正实现一个自己完全掌控的ftp服务器,可以个性化定制的ftp服务器. 正文: FTP服务器想 ...

  9. 服务端配置scan ip

    节点1确认当前监听状态 SQL> show parameter listener; NAME                                 TYPE        VALUE ...

  10. java.lang.reflection打印一个类的全部信息

    package com.ljy.chapter5; import java.lang.reflect.Constructor; import java.lang.reflect.Field; impo ...