poj 2506Tiling
来源:互联网 发布:数据存储的方式 编辑:程序博客网 时间:2024/06/13 22:50
<div class="ptt" lang="en-US" style="text-align: center; font-size: 18pt; font-weight: bold; color: blue;">Tiling</div><div class="plm" style="text-align: center;font-size:14px;"><table align="center"><tbody><tr><td><strong>Time Limit:</strong> 1000MS</td><td width="10px"> </td><td><strong>Memory Limit:</strong> 65536K</td></tr><tr><td><strong>Total Submissions:</strong> 9204</td><td width="10px"> </td><td><strong>Accepted:</strong> 4378</td></tr></tbody></table></div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Description</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tiling of a 2x17 rectangle. <center><img src="http://poj.org/images/2506_1.jpg" alt="" /></center></div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Input</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">Input is a sequence of lines, each line containing an integer number 0 <= n <= 250.</div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Output</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">For each line of input, output one integer number in a separate line giving the number of possible tilings of a 2xn rectangle. </div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Sample Input</p><pre class="sio" style="font-family: "Courier New", Courier, monospace;font-size:14px;">2812100200
Sample Output
317127318451004001521529343311354702511071292029505993517027974728227441735014801995855195223534251
#include<iostream>#include<stdio.h>using namespace std;int str[251][101];//用数组储存 一行一行的存int main(){ int i,j,t; str[0][0]=1;//0的时候 str[1][0]=1;//长度为一的时候 str[2][0]=3;//长度为三的时候 t=0;//临时变量 for( i = 3; i<=250 ;i++ )//一共250行 储存250种 { for(j=0; j<=100 ; j++)//用数组储存 { t += str[i-1][j] + 2*str[i-2][j];//递推公式 (这里储存的顺序是从个位开始的,方便相加) (包括了进位) str[i][j] = t%10;//储存当前位数的数,如果大于10 取余 进位 t=t/10;//看看是否需要进位 } } int n; while(~scanf("%d",&n)) { for(i=100;i>=0;i--) { if(str[n][i]!=0) break; } for(;i>=0;i--) printf("%d",str[n][i]); printf("\n"); } return 0;}
0 0
- POJ 2506 Tiling
- poj 2506Tiling
- Poj 2506 Tiling
- POJ 2506 Tiling
- POJ 2506 -TILING
- POJ 2506 Tiling
- POJ 2506:Tiling
- poj 2506 Tiling
- poj 2506 Tiling
- POJ 2506 Tiling
- poj 2506---Tiling
- POJ-2506-Tiling
- POJ 2506 Tiling
- POJ 2506 Tiling 高精度
- poj 2506 Tiling 【大数】
- poj 2506 Tiling
- poj-2506 Tiling
- poj 2506 Tiling
- python 导出hive数据表的schema
- java关键字this
- 企业级 J2EE 框架 Core-Classic
- [Java基础笔记]读写部分
- 表达式
- poj 2506Tiling
- Nutz logoJava应用框架 Nutz
- JSP里ContentType ,charset和pageEncoding的理解与区别
- 最长回文字符串
- 递归方式查找文件夹的所有文件
- 快10点了,天黑了,我睡了。。。
- Can not perform this action after onSaveInstanceState
- C++ 类的静态成员详细讲解
- lintcode coins-in-a-line-ii 硬币排成线ii