zoukankan      html  css  js  c++  java
  • B

    Problem description

    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
    解题思路:题目已经说的很清楚了,如果第i位是斐波那契数,就输出大写字母'O',否则输出小写字母'o',简单水过!
    AC代码:
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     int n,k=1,f[17]={1,1};
     6     for(int i=2;i<17;++i)//a[16]刚好超过1000,所以只需枚举到16即可
     7         f[i]=f[i-2]+f[i-1];
     8     cin>>n;
     9     for(int i=1;i<=n;++i){
    10         if(i==f[k]){cout<<'O';k++;}
    11         else cout<<'o';
    12     }
    13     cout<<endl;
    14     return 0;
    15 }
  • 相关阅读:
    BZOJ 1257 余数之和
    BZOJ 1251 序列终结者
    BZOJ 2716 [Violet 3]天使玩偶
    BZOJ 2648 SJY摆棋子
    HDU 1007 Quoit Design
    BZOJ 3504 危桥
    BZOJ 1877 晨跑
    玩转Web之SSH--Heibernate (一)---第一个demo
    网页信息抓取进阶 支持Js生成数据 Jsoup的不足之处
    2013-09-16 构建C1000K的服务器(1) – 基础
  • 原文地址:https://www.cnblogs.com/acgoto/p/9105251.html
Copyright © 2011-2022 走看看