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. Oracle和Redhat下载地址

    Oracle RedHat 用户名:zhangwei900808@126.com 密码:@XxxxxXxxxxxx 有网友想要的,请在留言板给我留言,我会把用户名和密码发给你!

  2. rsync介绍

    老套的搬用一下rsync的介绍,rsync是Linux系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync.rsync支持大多数的类Unix系统,无论是Linux.Sola ...

  3. C/C++中几种经典的垃圾回收算法

    1.引用计数算法 引用计数(Reference Counting)算法是每个对象计算指向它的指针的数量,当有一个指针指向自己时计数值加1:当删除一个指向自己的指针时,计数值减1,如果计数值减为0,说明 ...

  4. 分析java程序中cpu占用过高的线程

    http://blog.csdn.net/jgwei/article/details/12079147 http://hllvm.group.iteye.com/group/topic/38893 h ...

  5. POJ3283+字典树

    简单的字典树 /* 字典树 构造字典树.注意初始化! */ #include<stdio.h> #include<string.h> #include<stdlib.h& ...

  6. [译]C++书籍终极推荐

    转载声明: 翻译仅以技术学习和交流为目的,如需转载请务必标明原帖链接. 来源:http://stackoverflow.com/questions/388242/the-definitive-c-bo ...

  7. P38、面试题3:二维数组中的查找

    题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 首先选取数组中右上角的数字 ...

  8. 约瑟夫环问题-循环链表VS数组

    2013-08-18 21:27:50 循环链表.数组解决约瑟夫环问题的比较 注意几点: 循环链表的建立不难,在删除循环链表中元素时,用pCur->next != pCur判断结束: 每一轮计数 ...

  9. 摄像头(2)调用系统拍照activity来录像

    import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager ...

  10. Emulator control为灰色的情况

    新建了一个虚拟机,然后发现Emulator control为灰色,让eclipse重启下就可以了,然后就可以使用了.