zoukankan      html  css  js  c++  java
  • Eleven

    A. Eleven
    time limit per test :
    1 second
    memory limit per test: 
    256 megabytes
    input: 
    standard input
    output: 
    standard output

    Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters.

    Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested that the i-th letter of her name should be 'O' (uppercase) if i is a member of Fibonacci sequence, and 'o' (lowercase) otherwise. The letters in the name are numbered from 1 to n. Fibonacci sequence is the sequence f where

    • f1 = 1,
    • f2 = 1,
    • fn = fn - 2 + fn - 1 (n > 2).

    As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name.

    Input

    The first and only line of input contains an integer n (1 ≤ n ≤ 1000).

    Output

    Print Eleven's new name on the first and only line of output.

    Examples
    input
    8
    output
    OOOoOooO
    input
    15
    output
    OOOoOooOooooOoo
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int FB[1005];
     5 
     6 void init()
     7 {
     8     int t;
     9     for(int i = 1; i < 1005; i++)
    10         FB[i] = 0;
    11     FB[1] = FB[2] = 1;
    12     for(int i = 3; i < 1005;i++)
    13     {
    14 
    15         FB[i] = FB[i-1] + FB[i-2];
    16     }
    17 }
    18 
    19 int main()
    20 {
    21     init(); 
    22     int n;
    23 
    24 
    25     while(~scanf("%d",&n))
    26     {
    27             int temp = 2;
    28         for(int i = 1; i <= n; i++)
    29         {
    30             if(i == FB[temp])
    31             {
    32                 printf("O");
    33                 temp++;
    34             }
    35             else
    36             {
    37                 printf("o");
    38             }
    39         }
    40         printf("
    ");
    41     }
    42     return 0;
    43 }
  • 相关阅读:
    vijos 1167 南蛮图腾(打印图案)
    noj 1413 Weight 宁波 (dp)
    noj 1173 (宁波)Birdlike Angry Pig (暴力枚举)
    [1438] Get Up, Soldier! noj(宁波)
    [1441] Babelfish noj(宁波)
    长沙理工大学oj 1486: 文本整齐度 哈理工 1476(dp)
    noj 1414 (宁波) Rectangular Parallelopiped(sort+dp)
    8.6前端之内联框架
    8.5前端之Html样式和文本格式化
    8.5前端之类和id
  • 原文地址:https://www.cnblogs.com/jj81/p/8384673.html
Copyright © 2011-2022 走看看