Poj 1953 World Cup Noise之解题报告
World Cup Noise
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 16369 | Accepted: 8095 |
Description
"KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team
has reached the semifinals of the FIFA World Cup in their home country.
But although their excitement is real, the Korean people are still very
organized by nature. For example, they have organized huge trumpets
(that sound like blowing a ship's horn) to support their team playing on
the field. The fans want to keep the level of noise constant throughout
the match.
The trumpets are operated by compressed gas. However, if you blow
the trumpet for 2 seconds without stopping it will break. So when the
trumpet makes noise, everything is okay, but in a pause of the
trumpet,the fans must chant "KO-RE-A"!
Before the match, a group of fans gathers and decides on a chanting
pattern. The pattern is a sequence of 0's and 1's which is interpreted
in the following way: If the pattern shows a 1, the trumpet is blown. If
it shows a 0, the fans chant "KO-RE-A". To ensure that the trumpet will
not break, the pattern is not allowed to have two consecutive 1's in
it.
Problem
Given a positive integer n, determine the number of different
chanting patterns of this length, i.e., determine the number of n-bit
sequences that contain no adjacent 1's. For example, for n = 3 the
answer is 5 (sequences 000, 001, 010, 100, 101 are acceptable while 011,
110, 111 are not).
Input
For each scenario, you are given a single positive integer less than 45 on a line by itself.
Output
output for every scenario begins with a line containing "Scenario #i:",
where i is the number of the scenario starting at 1. Then print a
single line containing the number of n-bit sequences which have no
adjacent 1's. Terminate the output for the scenario with a blank line.
Sample Input
2
3
1
Sample Output
Scenario #1:
5 Scenario #2:
2
看到这题马上想到的就是斐波那契数列;
但是在做这题的时候一定要记得输出格式;
代码:
#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; const int maxn = ;
int choice[maxn]; int main(void)
{
int T,n;
choice[] = ;
choice[] = ;
for(int i=;i<=;++i)
choice[i] = choice[i-]+choice[i-];
scanf("%d",&T);
int cas = ;
while(T--)
{
scanf("%d",&n);
printf("Scenario #%d:\n",cas++);
cout<<choice[n]<<endl;
cout<<endl;
} return ;
}
Poj 1953 World Cup Noise之解题报告的更多相关文章
- POJ 1953 World Cup Noise
World Cup Noise Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14397 Accepted: 7129 ...
- poj 1953 World Cup Noise (dp)
World Cup Noise Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16774 Accepted: 8243 ...
- poj - 1953 - World Cup Noise(dp)
题意:n位长的01序列(0 < n < 45),但不能出现连续的两个1,问序列有多少种. 题目链接:id=1953" target="_blank">h ...
- POJ 1953 World Cup Noise(递推)
https://vjudge.net/problem/POJ-1953 题意:输入一个n,这n位数只由0和1组成,并且不能两个1相邻.计算共有多少种排列方法. 思路:递推题. 首先a[1]=2,a[2 ...
- poj 2284 That Nice Euler Circuit 解题报告
That Nice Euler Circuit Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 1975 Accepted ...
- poj 1094 Sorting It All Out 解题报告
题目链接:http://poj.org/problem?id=1094 题目意思:给出 n 个待排序的字母 和 m 种关系,问需要读到第 几 行可以确定这些字母的排列顺序或者有矛盾的地方,又或者虽然具 ...
- Poj 2081 Recaman's Sequence之解题报告
...
- POJ 1308 Is It A Tree? 解题报告
Is It A Tree? Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 32052 Accepted: 10876 D ...
- POJ 1958 Strange Towers of Hanoi 解题报告
Strange Towers of Hanoi 大体意思是要求\(n\)盘4的的hanoi tower问题. 总所周知,\(n\)盘3塔有递推公式\(d[i]=dp[i-1]*2+1\) 令\(f[i ...
随机推荐
- 实时数据处理环境搭建flume+kafka+storm:0.环境依赖
storm需要java和Python 部署依赖环境 --- 要求Java 6+ .Python 2.6.6+ java,python安装配置完成
- MyISAM读写并发优化
MyISAM在读操作占主导的情况下是很高效的.可一旦出现大量的读写并发,同InnoDB相比,MyISAM的效率就会直线下降,而 且,MyISAM和InnoDB的数据存储方式也有显著不同:通常,在MyI ...
- git初探
1 Linux下Git和GitHub环境的搭建 第一步: 安装Git,使用命令 "sudo apt-get install git" 第二步: 到GitHub上创建GitHub帐号 ...
- BZOJ 1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果
Description 每年万圣节,威斯康星的奶牛们都要打扮一番,出门在农场的N(1≤N≤100000)个牛棚里转悠,来采集糖果.她们每走到一个未曾经过的牛棚,就会采集这个棚里的1颗糖果. 农场不大, ...
- spoj 368
额 最小生成树 ........ #include <cstdio> #include <cstring> #include <algorithm> using ...
- pthread_create()之前的属性设置
一.pthread_create()之前的属性设置1.线程属性设置我们用pthread_create函数创建一个线程,在这个线程中,我们使用默认参数,即将该函数的第二个参数设为NULL.的确,对大多数 ...
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
学C++的时候,这几个输入函数弄的有点迷糊:这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行) 1.cin 2.cin.get ...
- MySQL exist
http://www.cnblogs.com/glory-jzx/archive/2012/07/19/2599215.html http://www.w3school.com.cn/sql/func ...
- HDMI介绍与流程
HDMI接口 http://baike.c114.net/view.asp?id=17671-21565442 DDC(Display Data Channel)通道用于HDMI发送和接收端之间交换一 ...
- C++对象的自销毁
记得在学校里的时候,曾经这样写过: void MyClass::KillMe() { delete this; } 老师看到这句话的时候,眼珠子都快瞪出来了.但是运行正确啊,没什么问题. 现在想起来, ...