zoukankan      html  css  js  c++  java
  • 【poj 1953 World Cup Noise】

    World Cup Noise
    Time Limit: 1000MS   Memory Limit: 30000K
    Total Submissions: 13155   Accepted: 6512

    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
     1 // Project name : 1953
     2 // File name    : main.cpp
     3 // Author       : Izumu
     4 // Date & Time  : Wed Jul 18 14:40:58 2012
     5 
     6 
     7 #include <iostream>
     8 #include <stdio.h>
     9 #include <string>
    10 #include <cmath>
    11 #include <algorithm>
    12 using namespace std;
    13 
    14 typedef unsigned long long int longint;
    15 
    16 longint a[50];
    17 
    18 void init()
    19 {
    20     a[0] = 1;
    21     a[1] = 2;
    22     for (int i = 2; i < 50; i++)
    23     {
    24         a[i] = a[i-1] + a[i-2];
    25     }
    26 }
    27 
    28 int main()
    29 {
    30     init();
    31     int t;
    32     cin >> t;
    33     for (int count = 1; count <= t; count++)
    34     {
    35         int n;
    36         cin >> n;
    37         cout << "Scenario #" << count << ":" << endl << a[n] << endl << endl;
    38     }
    39     return 0;
    40 }
    41 
    42 // end 
    43 // ism 
  • 相关阅读:
    最大期望算法 Expectation Maximization概念
    Apriori 关联算法学习
    mysql小问题
    C4.5决策树算法概念学习
    线性回归概念学习
    决策树概念学习
    Flink on Yarn运行机制
    Flink单机版安装与wordCount
    Kmeans算法学习与SparkMlLib Kmeans算法尝试
    数据挖掘10大算法详细介绍
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2597376.html
Copyright © 2011-2022 走看看