泰州市2018年程序设计竞赛第四题
#include<bits/stdc++.h>
using namespace std;
string s;
void work(int left,int right)
{ if(left==right)
{
if(s[left]=='B')//B是字符,注意用单引号
cout<<0;
else cout<<1;
return;
}
int len=(right-left)/2;
work(left,left+len-1);
work(left+len,right-1);
}
int main(){
cin>>s;
int lenuuuu=s.length();
work(0,lenuuuu-1);//注意字符总是从0开始计数
return 0;
}