人生第一次CF炸裂掉了13的rating,只写了两道签到题,真的菜

T1:

输出一个长度为n的字符串,对于第i位,如果i是斐波那契数,输出O 否则输出o

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<cmath>
 6 #include<algorithm>
 7 #include<queue>
 8 #include<vector>
 9 #include<map>
10 #define inf 2139062143
11 #define ll long long
12 #define MAXN
13 #define MOD
14 using namespace std;
15 inline int read()
16 {
17     int x=0,f=1;char ch=getchar();
18     while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
19     while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
20     return x*f;
21 }
22 int n,a=1,b=1,c;
23 bool hsh[1001];
24 int main()
25 {
26     n=read();
27     hsh[1]=1;
28     while(c<=n) c=a+b,a=b,b=c,hsh[c]=1;
29     for(int i=1;i<=n;i++)
30         if(hsh[i])cout<<'O';
31         else cout<<'o';
32 }
View Code

相关文章:

  • 2021-08-12
  • 2021-04-24
  • 2021-12-04
  • 2021-11-19
  • 2021-04-27
  • 2021-08-14
  • 2021-08-20
猜你喜欢
  • 2022-03-07
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案