博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 题目2506Tiling(大数)
阅读量:7126 次
发布时间:2019-06-28

本文共 1044 字,大约阅读时间需要 3 分钟。

Tiling
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8128   Accepted: 3941

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

2812100200

Sample Output

317127318451004001521529343311354702511071292029505993517027974728227441735014801995855195223534251

Source

公式a[n]=a[n-1]+a[n-2]*2

ac代码

#include
#include
int str[255][100];void fun(){ str[0][0]=1; str[1][0]=1; str[2][0]=3; int temp,i,j; temp=0; for(i=3;i<=250;i++) { for(j=0;j<100;j++) { temp+=(str[i-2][j])*2+str[i-1][j]; str[i][j]=temp%10; temp/=10; } }}int main(){ fun(); int n; while(scanf("%d",&n)!=EOF) { int i; for(i=99;i>=0;i--) { if(str[n][i]!=0) break; } for(;i>=0;i--) { printf("%d",str[n][i]); } printf("\n"); } }

转载地址:http://gmhel.baihongyu.com/

你可能感兴趣的文章
centOS 安装mp4box
查看>>
iOS中堆和栈的区别
查看>>
C语言之结构体
查看>>
linux globbing文件通配符
查看>>
Linux系统下查看命令属于哪个安装包
查看>>
C++拷贝构造函数详解
查看>>
Windows Server 2008 安装完活动目录后必要的检查
查看>>
一文为你详细讲解对象映射库【AutoMapper】所支持场景
查看>>
我的友情链接
查看>>
Mongod的复制
查看>>
Linux中find常见用法示例
查看>>
浅谈系统性能优化
查看>>
搭建Python环境与Python文件类型
查看>>
安装Tengine php mysql
查看>>
实战:mysql检查物理磁盘中的二进制日志文件是否有丢失
查看>>
检查mysql错误日志并发邮件通知
查看>>
【linux+C】通过几个实例温习指针
查看>>
华为刀片网卡漂移问题
查看>>
搜索专题:Balloons
查看>>
使用shell脚本采集系统cpu、内存、磁盘、网络等信息
查看>>