Files
python/TangDou/XiTi/1406_4.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

31 lines
728 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
//声明FBI函数
char FBI(string s);
int main() {
int n;
cin >> n;
string s;
cin >> s;
cout << FBI(s);
return 0;
}
//FBI函数(递归函数)的实现
char FBI(string s) {
if (s.length() > 1) {
//输出左
cout << FBI(s.substr(0, s.length() / 2));
//输出右
cout << FBI(s.substr(s.length() / 2, s.length() / 2));
}
// http://c.biancheng.net/view/400.html
if (s == string(s.length(), '0')) return 'B'; //通过string的构造函数,构建s.length()长度的0组成的字符串
if (s == string(s.length(), '1')) return 'I';
//混搭的输出F
return 'F';
}