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. poj 2226 Muddy Fields (转化成二分图的最小覆盖)

    http://poj.org/problem?id=2226 Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  2. oracle 导出数据和导入数据

    导出数据 exp zl_gj/zlkj@gqxt  grants=y tables=(zl_gj.ckgj,zl_gj.gjlx,zl_gj.rkgj) file=c:\gj.dmp log=c:\g ...

  3. scrum敏捷开发

    团队PM:袁佩佩 scrum敏捷开发计划制定: 确定项目实施具体阶段目标 确定项目相关任务分解 确定每日站立会议进行计划 确定项目计划总结日程 确定风险解决方案

  4. OSUnMapTbl[]的原理

    问题描述:     ucos任务队列中优先级获取 问题解决: uCOS-II是一个多任务的操作系统,每个任务都是一个应用程序,它有自己的寄存器和堆栈空间,即任务控制块TCB(task control ...

  5. 1962-Fibonacci

    描述 This is an easy problem.I think Fibonacci sequence is familiar to you.Now there is another one. H ...

  6. maven3常用命令\创建Project

    转自 http://blog.csdn.net/edward0830ly/article/details/8748986 ------------------------------maven3常用命 ...

  7. ubuntu下如何设置主机名

    方法如下: 在终端输入 hostname 查看主机名主机名存放在/etc/hostname中 ,sudo gedit /etc/hostname 修改后保存/etc/hosts 还有一份 , sudo ...

  8. SaaS系列介绍之八: SaaS的运营模式

    1 引言 软件的核心是它为用户解决领域相关问题的能力.               ________Eric Evans,<领域驱动设计> 传统的软件生命周期中,软件的维护占整个过程的70 ...

  9. Java中JSON的简单使用与前端解析

    http://www.blogjava.net/qileilove/archive/2014/06/13/414694.html 一.JSON JSON(JavaScript Object Notat ...

  10. Retrofit初识

    Retrofit Retrofit是一套RESTful架构的Android(Java)客户端实现,基于注解,提供JSON to POJO(Plain Ordinary Java Object,简单Ja ...