POJ 2506
来源:互联网 发布:淘宝如何分期买手机 编辑:程序博客网 时间:2024/06/08 14:13
Tiling
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7255 Accepted: 3528
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
Source
The UofA Local 2000.10.14
好久没有写大数了 出了好多细节性的问题 恶心的要死啊
而且一开始公式推错了
正确公式应该是f(n)=f(n-1)+2*f(n-2);
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <ctype.h>#include <iostream>#include <algorithm>#include <map>#include <string>#include <vector>using namespace std;int main(){ int num[251][301]; memset(num,0,sizeof(num)); num[0][0]=1; num[1][0]=1; for(int i=2; i<=250; i++) { for(int j=0; j<300; j++) num[i][j]=num[i-1][j]+2*num[i-2][j]; for(int j=0; j<300; j++) { if(num[i][j]>=10) { num[i][j+1]+=num[i][j]/10; num[i][j]%=10; } } } int n; while(cin>>n) { int c=0; for(int i=300; i>=0; i--) if(num[n][i]!=0) { c=i; //cout<<"c "<<c<<endl; break; } for(int j=c; j>=0; j--) cout<<num[n][j]; cout<<endl; } 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
- iOS 异步下载图片
- 常用docker命令,及一些坑
- 虚拟机的启动内核日志
- diary20140515---深邃之思-movie
- 推荐一本好书:《Linux从入门到精通》(刘忆智)
- POJ 2506
- Leetcode_word-ladder(c++ version)
- 【原创】Source Insight入门、简单配置和简单技巧
- ubuntu/centos 网络配置记录
- Linux下sed 指令详解。
- SSH框架问题——java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener报错
- C语言学习资源推荐
- android ImageView scaleType属性
- 拓扑入门 poj2367 Genealogical tree