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. Sql查询除ID以外相同的数据

    id    NAME    AGE1    n1         12    n1         13    n2         24    n2         25    n22       ...

  2. Linux学习笔记(4)-文本编辑器vi的使用

    vi的三种编辑模式 命令模式(Command mode) 在此模式下可以控制光标的移动,可以删除字符,删除行,还可以对某个段落进行复制和移动 输入模式(Insert mode) 只有在此模式下,可以输 ...

  3. log4j日志输出到web项目指定文件夹

    感谢 eric2500 的这篇文章:http://www.cxyclub.cn/n/27860/ 摘要:尝试将log4j的文件日志输出到web工程制定目录,遇到了很多问题,最终在eric2500的指导 ...

  4. jquery 对 Json 的各种遍历

    grep <script type='text/javascript' src="/jquery.js"></script> <script type ...

  5. [转载]C#导入XLS数据到数据库

    Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...

  6. CSRF之攻击与防御

    0x01 什么是CSRF攻击 CSRF是Cross Site Request Forgery的缩写(也缩写为XSRF),直译过来就是跨站请求伪造的意思,也就是在用户会话下对某个CGI做一些GET/PO ...

  7. 酷摄影:关于梦 - Miki takahashi

    这组摄影来自于日本东京摄影师 Miki takahashi 是一组双重曝光摄影,分开看也许很平常,但是结合在一起却非常有韵味. [gallery]

  8. printf在终端输出时改变颜色

    在调试程序时,有时候要输出大量数据,如果让printf/fprintf改变输出数据的颜色,那观察数据就方便多了. 终端的字符颜色是用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关.转义序 ...

  9. linux netstat命令使用详解

    快速应用 netstat -lnp | more 显示监听的端口 简介 Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),mas ...

  10. Amzon MWS API开发之订单接口

    Amazon订单接口是Amazon MWS 开发接口中的一大块,我们可以通过接口调用来获得订单数据. 在调用接口之前,首先我们要获得相关店铺商家的店铺密钥等信息.如下: 在此我将所有信息定义在一个类中 ...