UVa, 900 Brick Wall Patterns
来源:互联网 发布:iphone通话录音软件 编辑:程序博客网 时间:2024/04/29 18:21
Brick Wall Patterns
If we want to build a brick wall out of the usual size of brick which has a length twice as long as its height, and if our wall is to be two units tall, we can make our wall in a number of patterns, depending on how long we want it. From the figure one observe that:
- There is just one wall pattern which is 1 unit wide - made by putting the brick on its end.
- There are 2 patterns for a wall of length 2: two side-ways bricks laid on top of each other and two bricks long-ways up put next to each other.
- There are three patterns for walls of length 3.
Problem
Your task is to write a program that given the length of a wall, determines how many patterns there may be for a wall of that length.Intput
Your program receives a sequence of positive integers, one per line, each representing the length of a wall. The maximum value for the wall is length 50. The input terminates with a 0.Output
For each wall length given in the input, your program must output the corresponding number of different patterns for such a wall in a separate line.Sample Intput
1230
Sample Output
123
#include<iostream>using namespace std;int main(){ int n,i; int a[100]; a[1]=1; a[2]=2; for(i=3;i<100;i++) { a[i]=a[i-2]+a[i-1]; } while(cin>>n) { if(n==0) break; cout<<a[n]<<endl; } return 0;}
- UVA 900 Brick Wall Patterns
- UVa, 900 Brick Wall Patterns
- UVa 900 - Brick Wall Patterns
- UVa900 - Brick Wall Patterns
- Brick Wall Patterns
- uva_900 - Brick Wall Patterns( 遞推 )
- Brick Wall
- Brick Wall
- Brick Wall
- Leetcode-554. Brick Wall
- [leetcode] 554. Brick Wall
- 554. Brick Wall
- 554. Brick Wall
- [LeetCode]554. Brick Wall
- 554. Brick Wall
- [LeetCode]554. Brick Wall
- 554. Brick Wall
- [leetcode]554. Brick Wall
- Unity3D开发(三):场景管理插件Scene Manager
- Android Studio工程列表没有文件夹,如何恢复默认设置
- 分组交换
- UVa, 11000 Bee
- Android BaseAdapter
- UVa, 900 Brick Wall Patterns
- UVa 374 Big Mod (快速幂取模)
- 【rmzt:彩虹6号爱国者主题下载】
- IP地址 、子网计算
- UVa, 580 Critical Mass
- Failed to load libGL.so about ubuntu
- linux 按键驱动
- 关于数组指针和指针数组
- 指针轻松破除访问属性