提交时间:2023-08-23 14:43:14

运行 ID: 99648

#include<iostream> #include<string> #include<cmath> using namespace std; string s; void FBI(int x,int y){ if (y > x){ FBI(x,(x + y) / 2); FBI((x + y) / 2 + 1,y); } bool B = true,I = true; for (int i = x;i <= y;i++){ if (s[i] == '1'){ B = false; } if (s[i] == '0'){ I = false; } } if (B){ cout<<"B"; } else if (I){ cout<<"I"; } else{ cout<<"F"; } } int main(){ int n; cin>>n>>s; FBI(0,pow(2,n) - 1); return 0; }