mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
20 lines
376 B
C++
20 lines
376 B
C++
|
#include<iostream>
|
||
|
#include<string>
|
||
|
using namespace std;
|
||
|
string s;
|
||
|
long long cal(long long x,char goal)
|
||
|
{
|
||
|
for(long long i=x;i>=0;i--)
|
||
|
if(s[i]!=goal) return cal(i-1,'A'^'B'^'C'^goal^s[i])+(1LL<<i);
|
||
|
return 0;
|
||
|
}
|
||
|
int main()
|
||
|
{
|
||
|
while(cin>>s,s!="X")
|
||
|
{
|
||
|
long long ans=cal(s.length()-1,'B');
|
||
|
cout<<ans<<endl;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|