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.
![](https://i-blog.csdnimg.cn/blog_migrate/38e7f6a0697e852707e7e0892449aeb2.png)
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
题意:输出一个长度为N的字符串,其中第i个位置是斐波那契数的话,输出O,否则是o
思路:N只有1000,斐波那契第16项已经超过1000,所以打一个20的表就够用了,对应第字符串第i个位置是否在表中,输出大小o就可以了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<queue>
#include<vector>
#include<map>
#define ll long long
using namespace std;
ll vis[100010],sum[50];
ll n;
int main()
{
memset(vis,0,sizeof(vis));
vis[1]=1;
sum[0]=1;sum[1]=1;
for(ll i=2;i<=20;i++)
{
sum[i]=sum[i-1]+sum[i-2];
vis[sum[i]]=1;
}
while(~scanf("%lld",&n))
{
for(ll i=1;i<=n;i++)
{
if(vis[i]==1)printf("O");
else printf("o");
}
printf("\n");
}
return 0;
}