World Cup Noise

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 16369   Accepted: 8095

Description

Background
"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

The first line contains the number of scenarios.

For each scenario, you are given a single positive integer less than 45 on a line by itself.

Output

The
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之解题报告的更多相关文章

  1. POJ 1953 World Cup Noise

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14397   Accepted: 7129 ...

  2. poj 1953 World Cup Noise (dp)

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16774   Accepted: 8243 ...

  3. poj - 1953 - World Cup Noise(dp)

    题意:n位长的01序列(0 < n < 45),但不能出现连续的两个1,问序列有多少种. 题目链接:id=1953" target="_blank">h ...

  4. POJ 1953 World Cup Noise(递推)

    https://vjudge.net/problem/POJ-1953 题意:输入一个n,这n位数只由0和1组成,并且不能两个1相邻.计算共有多少种排列方法. 思路:递推题. 首先a[1]=2,a[2 ...

  5. poj 2284 That Nice Euler Circuit 解题报告

    That Nice Euler Circuit Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 1975   Accepted ...

  6. poj 1094 Sorting It All Out 解题报告

    题目链接:http://poj.org/problem?id=1094 题目意思:给出 n 个待排序的字母 和 m 种关系,问需要读到第 几 行可以确定这些字母的排列顺序或者有矛盾的地方,又或者虽然具 ...

  7. Poj 2081 Recaman's Sequence之解题报告

                                                                                                         ...

  8. POJ 1308 Is It A Tree? 解题报告

    Is It A Tree? Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 32052   Accepted: 10876 D ...

  9. 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 ...

随机推荐

  1. MoonWarriors-lua——《雷电战机》游戏-Lua移植版

    MoonWarriors是一个使用Cocos2d-Html5引擎开发的类似雷电战机的游戏Demo,源代码发布在Cocos2d-x官网的引擎示例当中.MoonWarriors-lua是为了学习Cocos ...

  2. maven eclipse web项目流程(简化内容)

    1.maven eclipse 环境搭建 1.1 下载解压配置环境变量(解压.环境变量maven目录到bin.setting.xml 改本地仓库) 1.2 eclipse插件安装配置(link安装.加 ...

  3. uva 1377

    比较不错的一个题,关键是理解状态转移 #include<algorithm> #include<cstdio> #include<cstring> #include ...

  4. 在NEXUS中加入自己定义的第三方PROXIES代理库

    就是要等会耐心,更新好之后,才能在PUBLIC库里进行操作. 下图是JBOSS的

  5. linux bash_profile和.bashrc区别

    经常在一些技术类的文章中提到修改bash_profile和.bashrc这两个文件,也算是使用频率比较高的两个文件吧,但实现同样一个功能,有的教程里说修改bash_profile这个文件,有的教程里却 ...

  6. BZOJ 3747 POI2015 Kinoman

    因为上午没有准备够题目,结果发现写完这道题没题可写了QAQ 又因为这道题范围是100w,我写了发线段树,以为要T,上午就花了一个小时拼命卡常数 结果下午一交居然过了QAQ 我们考虑枚举L,求最大R使得 ...

  7. SaaS系列介绍之七: SaaS模式分析(下)

    1 SaaS模式下的质量管理 质量管理是从事SaaS事业的企业管理的重要课题,质量管理的职能是质量方针.质量目标和质量指标的制定和贯彻实施,中心目标是促进产品质量.提高客户满意度. 软件质量要素包含以 ...

  8. rand5()产生rand7()

    http://www.cnblogs.com/dwdxdy/archive/2012/07/28/2613135.html 利用rand5()产生rand7().rand5()产生1到5的整数,ran ...

  9. WPF之Behavior

    本文主要是以实现拖动元素作为例子. 创建Behavior: 通常这个类会继承自Behavior<T>,其中T就是此Behavior服务的对象,在此处使用的是UIElement,也就是虽有的 ...

  10. MyBatis的动态SQL操作--更新

    更新条件不确定,需要根据具体的情况生成sql语句. id是主键,一般不会去更新. 1.只更新name的值 update student set name = ? where id = ? 2.只更新s ...