poj 2506
来源:互联网 发布:php 工作流 编辑:程序博客网 时间:2024/05/18 06:18
Tiling
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7303 Accepted: 3555
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.
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//打表方法和大数相加 递推#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>int f[255][200];int main(){ int n,i,j,c,ans; memset(f,0,sizeof(f)); f[0][0]=1; f[1][0]=1; f[2][0]=3; for(i=3; i<=250; i++) { c=0; for(j=0; j<200; j++) { ans=f[i-1][j]+2*f[i-2][j]+c; //递推公式 f[n]=f[n-1]+2*f[n-2]; f[i][j]=ans%10000; c=ans/10000; } } while(scanf("%d",&n)!=EOF) { for(i=199; i>=0; i--) //忽略前导零 { if(f[n][i]==0) ; else break; } printf("%d",f[n][i]); i--; for(; i>=0; i--) printf("%04d",f[n][i]); //输出4位 不足4位的补零 printf("\n"); } return 0;}
0 0
- poj 2506
- poj 2506
- poj 2506
- POJ 2506
- poj 2506
- POJ 2506
- poj--2506
- poj 2506
- poj 2506
- POJ 2506
- POJ 2506 Tiling
- POJ 2506 Tilling
- poj 2506Tiling
- POJ 2506 递归 + 高精度
- Poj 2506 Tiling
- POJ 2506 Tiling
- POJ 2506 -TILING
- POJ 2506 Tiling
- 一键设置Java环境变量
- django notes 3 Template variables
- Java 多线程实例讲解综述
- MATLAB编程语言和IDE
- Java类加载器
- poj 2506
- Spring和ActiveMQ集成实现队列消息以及PUB/SUB模型
- 杂知识
- 剖析Force.com的多租户架构(5)- 总结
- int main(int argc, char* argv[])
- PreparedStatement和Statement区别
- 小结九种图
- JNI编程:C++回调Java函数
- 记一次在linux 平台上的优化调试