id=2506">http://poj.org/problem?id=2506

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

做之前看看这个:http://blog.csdn.net/yuzhiwei1995/article/details/47909743

n==0时输出1 神数据。wa了n次这个地方

//贴两种大数进位方式

#include<stdio.h>
#include<string.h>
int a[300][2010];
void fun()
{
int i,j;
memset(a,0,sizeof(a));
a[0][0]=1;
a[1][0]=1;
a[2][0]=3;
int t;
for(i=3;i<=260;++i)
{
int k=0;
for(j=0;j<=2000;++j)
{
a[i][j] += a[i-1][j] + 2 * a[i-2][j];
if(a[i][j]>=10)
{
a[i][j+1]=a[i][j]/10;
a[i][j]%=10;
}
}
}
}
int main()
{
int n,i;
fun();
while(~scanf("%d",&n))
{
for(i=2000;i>0&&a[n][i]==0;--i);
for(;i>=0;--i)
printf("%d",a[n][i]);
printf("\n");
}
return 0;
}

#include<stdio.h>
#include<string.h>
int a[300][2010];
void fun()
{
int i,j;
memset(a,0,sizeof(a));
a[0][0]=1;
a[1][0]=1;
a[2][0]=3;
int t;
for(i=3;i<=260;++i)
{
int k=0;
for(j=0;j<=2000;++j)
{
t = a[i-1][j] + 2 * a[i-2][j] + k;
k=t / 10;
a[i][j]=t%10;
}
}
}
int main()
{
int n,i;
fun();
while(~scanf("%d",&n))
{
for(i=2000;i>0&&a[n][i]==0;--i);
for(;i>=0;--i)
printf("%d",a[n][i]);
printf("\n");
}
return 0;
}

Tiling POJ 2506 【大数】的更多相关文章

  1. poj 2506 Tiling(递推 大数)

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

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

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

  3. poj 2506 Tiling(大数+规律)

    poj2506Tiling 此题规律:A[0]=1;A[1]=1;A[2]=3;--A[n]=A[n-1]+2*A[n-2];用大数来写,AC代码: #include<stdio.h> # ...

  4. POJ 2506 Tiling dp+大数 水题

    大致题意:现有两种方块(1X2,2X2),方块数量无限制.问用这两种方块填满2Xn的矩阵的填法有多少种. 分析:通俗点说,找规律.专业化一点,动态规划. 状态d[i],表示宽度为i的填法个数. 状态转 ...

  5. poj 2506 Tiling(java解法)

    题目链接:id=2506">http://poj.org/problem?id=2506 本题用的java解的.由于涉及到大数问题,假设对java中的大数操作不熟悉请点这儿:链接 思路 ...

  6. poj 2506 Tiling 递推

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

  7. [ACM] POJ 2506 Tiling (递归,睑板)

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7487   Accepted: 3661 Descriptio ...

  8. POJ 2506 Tiling(递推+大整数加法)

    http://poj.org/problem?id=2506 题意: 思路:递推.a[i]=a[i-1]+2*a[i-2]. 计算的时候是大整数加法.错了好久,忘记考虑1了...晕倒. #includ ...

  9. POJ 2506 Tiling

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7437   Accepted: 3635 Descriptio ...

随机推荐

  1. Hibernate_9_Person和IdCard实例_一对一关系:基于主键

    1)建立Person类:(与8同样) 2)建立IdCard类:(与8同样) 3)建立持久化类:  1>保存方法(与8同样)  2>获取方法(与8同样)  3>删除方法(与8同样)   ...

  2. [JZOJ3385] [NOIP2013模拟] 黑魔法师之门 解题报告(并查集)

    Description 经过了16个工作日的紧张忙碌,未来的人类终于收集到了足够的能源.然而在与Violet星球的战争中,由于Z副官的愚蠢,地球的领袖applepi被邪恶的黑魔法师Vani囚禁在了Vi ...

  3. AngularJs轻松入门源码托管至Github

    Github是全球最大的代码托管平台,笔者玩Github有一段时间了,有很多开源项目的源码都托管在Github上,笔者在上面也发现了不少优秀的开源代码. 每次写完博文想在最后附上文章相关的代码,但是由 ...

  4. sql的系统关键字的概述

    create proc proc_B as SELECT * FROM [ZkbTest].[dbo].[T_ZKB] exec sp_helptext proc_B select * from sy ...

  5. UI Framework-1: Aura Views

    Views Views is a user interface framework built on a type called, confusingly, View. Responsible for ...

  6. UI Framework-1: views Windowing

    views Windowing views provides support for creating dialog boxes and other kinds of windows through ...

  7. 【Codeforces Round #239 (Div. 1) A】Triangle

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后的直角三角形可以通过平移,将直角顶点移动到坐标原点. 然后我们只要枚举另外两个点其中一个点的坐标就好了. x坐标的范围是[1.. ...

  8. CSU 1510 Happy Robot

    1510: Happy Robot Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 19  Solved: 7 Description Input The ...

  9. 洛谷——P3374 【模板】树状数组 1

    https://www.luogu.org/problem/show?pid=3374 题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 输入输 ...

  10. 华为:一张图看懂 HBase

    来自为知笔记(Wiz)