Codeforces Round #459 (Div. 2) A. Eleven 水题

Eleven的朋友建议她选择一个由特定数量的大写'O'和小写'o'组成的新名字,其中大写'O'的位置由Fibonacci数列决定。本篇介绍了生成这个名字的算法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

#include <bits/stdc++.h>
using namespace std;

int f[1100],num[11000];

int main()
{
    int n;
    f[0]=1;
    f[1]=1;
    for (int i=2;i<1010;i++)
        f[i]=f[i-1]+f[i-2];
    while (cin>>n){
        memset(num,0,sizeof(num));
        for (int i=1;i<20;i++){
            num[f[i]]=1;
        }

        char ans[1100];
        for (int i=1;i<=n;i++){
            if (num[i]==1)
                ans[i]='O';
            else
                ans[i]='o';
        }
        for (int i=1;i<=n;i++)
            cout<<ans[i];
        cout<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值