本文主要是介绍codeforces 918A Eleven,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
点击打开链接
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.
The first and only line of input contains an integer n (1 ≤ n ≤ 1000).
Print Eleven's new name on the first and only line of output.
8
OOOoOooO
15
OOOoOooOooooOoo
水题
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
char a[1005];
int b[1005];
int main()
{ // freopen("shuju.txt","r",stdin);memset(a,'o',sizeof(a));a[1]='O';a[2]='O';b[1]=1;b[2]=1;for(int i=3;;i++){b[i]=b[i-2]+b[i-1];a[b[i]]='O';if(b[i]>1000)break;}int n; cin>>n;for(int i=1;i<=n;i++)printf("%c",a[i]);printf("\n");return 0;
}
这篇关于codeforces 918A Eleven的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!