计算2*n的矩形能拆分成几种由2*1,2*2组成的情况
来源:互联网 发布:快速软件开发 微盘 编辑:程序博客网 时间:2024/05/11 05:18
关键找到规律,然后解决数字计算和输出的问题
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<string.h> int a[251][101]; int main() { int n,m,i,j; a[0][100]=0; a[1][100]=1; a[2][100]=3; for(i=3;i<=250;i++) { for(j=100;j>=0;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; } } } while(scanf("%d",&n)!=EOF) { if(n <= 0||n>250) printf("error\n"); else { for(i=0;i<=100;i++) if(a[n][i]!=0) break; m=i; for(j=m;j<=100;j++) printf("%d",a[n][j]); printf("\n"); } } return 0; }
阅读全文
0 0
- 计算2*n的矩形能拆分成几种由2*1,2*2组成的情况
- 计算1!+2!+3!+...n!的值,n由键盘输入
- 15_由1、2、3、4四个数字,能组成多少个互不相同且一个数字中无重复数字的三位数?
- TopCoder--计算矩形的公有面积2
- 第五周-2计算矩形的面积
- 给定正整数n和m,计算出n个元素的集合{1,2,...,n}可以划分为多少个不同的由m个元素组成的子集合
- HDU 1398 n由i^2(i=1,2,3..17)组成的方案数(母函数 || 完全背包)
- 编写函数int stat(int a[],int n,int c[][2]).a指向的数组中保存了由n个1位整数组成的数列(n为偶数)。
- 某个数数的N倍全由1组成
- 打印由0-n组成的三角形
- 计算由N个五角形组成的圈的生成树的数目
- hdu 3746 Cyclic Nacklace(求最少添加几个字符使得字符串是由n(n>=2)个循环节组成的)
- POJ 2229-Sumsets(把n拆分为2的幂相加的拆分种数)
- 计算2的n次方
- 计算2的N次方
- 有 1、 2、 3、 4 个数字, 能组成多少个互不相同且无重复数字的三位数? 计算并打印出这些数字
- 由1,2,4,8,16...相加组成的数,如何快速确定组合数
- 计算1+2+3+。。。。+n的值
- LeetCode#1 Two Sum题解(C++版)
- linux下C语言编写贪吃蛇游戏
- c++对指针的认识
- jQuery添加更多信息
- 安全从业人员常用工具指引
- 计算2*n的矩形能拆分成几种由2*1,2*2组成的情况
- 《inside Bluetooth low energy》note_02
- 数据库表-权限表应用
- 【LeetCode算法练习(C语言)】 Longest Palindromic Substring
- C
- 快速排序
- SpringCloud-----SpringCloud不能启动所有服务解决方案
- Java Mail------邮件(附件图片)
- 常用正则