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. 8.ES6测试

    转自:http://www.ruanyifeng.com/blog/2015/12/a-mocha-tutorial-of-examples.html 如果测试脚本是用ES6写的,那么运行测试之前,需 ...

  2. 设计url 通过分发的方式 Xadmin_demo

    如 urlpatterns = [ url(r'^Xadmin/',([ url(r'^add/$', views.add) url(r'^delete/$', views.delete) ], No ...

  3. spring-data-redis 使用过程中需要注意的地方

    1.序列化问题 <!-- SDR默认采用的序列化策略有两种,一种是String的序列化策略,一种是JDK的序列化策略. StringRedisTemplate默认采用的是String的序列化策略 ...

  4. SpringMVC后台使用对象接受参数字符串转日期

    在springMVC配置文件中加入: <bean id="dateConvert" class="com.iomp.util.DateConvert"/& ...

  5. C#后台请求其它网站页面

    /// <summary> /// 指定Post地址使用Get 方式获取全部字符串 /// </summary> /// <param name="url&qu ...

  6. iOS单例创建的一点疑惑

    线程安全的单例常用写法, +(AccountManager *)sharedManager{ static AccountManager *defaultManager = nil; disptch_ ...

  7. js一些常用方法

    string 增加 IsNullorEmpty : String.prototype.IsNullOrEmpty = function (r) {    if (r === undefined || ...

  8. Futures and promises

    In computer science, future, promise, delay, and deferred refer to constructs used for synchronizing ...

  9. caffe(9) caffe例子

    为了程序的简洁,在caffe中是不带练习数据的,因此需要自己去下载.但在caffe根目录下的data文件夹里,作者已经为我们编写好了下载数据的脚本文件,我们只需要联网,运行这些脚本文件就行了. 注意: ...

  10. SPFA的小优化

    标签:闲扯 SPFA的小优化 1. 向队尾加入元素时,如果它比对首还优,就把把它直接和队首交换. 拿一个双端队列来实现 (手写 , head ,tail   STLdeque亲测及其慢) 这个小优化其 ...