先预处理出每个1000以内的数是否是斐波那契数,然后按照题意模拟即可
#include <bits/stdc++.h>
using namespace std;
int x[1010];
int main() {
int n, a, b, c;
cin >> n; a = 1, b = 1;
while (b <= 1000) {
x[b] = 1;
int o = a; a = b, b = o + b;
}
for (int i = 1; i <= n; i++) if (x[i]) printf("O"); else printf("o");
return 0;
}
???
4评论???
不才1个吗???