zoukankan      html  css  js  c++  java
  • Codeforces Round #459 (Div. 2)-A. Eleven

    A. Eleven

    time limit per test1 second
    memory limit per test256 megabytes

    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


    解题心得:

    1. 就是考的一个斐波那契的问题,很简单。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int maxn = 1e5+100;
    int num[maxn];
    bool vis[maxn];
    int main()
    {
       memset(num,0,sizeof(num));
       memset(vis,0,sizeof(vis));
       num[0] = 1,num[1] = 1;
       int n;
       scanf("%d",&n);
       for(int i=2;;i++)
       {
           num[i] = num[i-1] + num[i-2];
           vis[num[i]] = true;
           if(num[i] > 3000)
                break;
       }
       vis[1] = true;
       for(int i=1;i<=n;i++)
            if(vis[i])
                printf("O");
            else
                printf("o");
        return 0;
    }
  • 相关阅读:
    bash /root/.bashrc permission denied
    vscode 在ubuntu的terminal中下划线不显示解决方案
    基于SSH框架的考勤管理系统的设计与实现
    关于《实验一》的框架选择
    认知架构
    《软件需求》读书笔记3
    《软件需求》读书笔记1
    《软件需求》读书笔记2
    《软件方法》读书笔记2
    《软件方法》读书笔记3
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107189.html
Copyright © 2011-2022 走看看