#include <iostream>
#include <string>
using namespace std;
int main(){
string s;
int t;
cin>>t;
t=1;
while(cin>>s){
cout<<"Case "<<t++<<": ";
int sum=0,count=0;
int a[3]={0,0,0};
for(int i=0;i<s.size();i++)
sum+=(s[i]-'0'),a[(s[i]-'0')%3]++;
if(sum%3==0){
count+=a[0];
if(a[1]+a[2]==1)
count++;
}
else if(sum%3==1&&a[1]){
count++;
count+=a[0];
if(a[1]+a[2]==2)
count++;
}
else if(sum%3==2&&a[2]){
count++;
count+=a[0];
if(a[1]+a[2]==2)
count++;
}
if(count&1)
cout<<"S";
else
cout<<"T";
cout<<endl;
}
}
#include <string>
using namespace std;
int main(){
string s;
int t;
cin>>t;
t=1;
while(cin>>s){
cout<<"Case "<<t++<<": ";
int sum=0,count=0;
int a[3]={0,0,0};
for(int i=0;i<s.size();i++)
sum+=(s[i]-'0'),a[(s[i]-'0')%3]++;
if(sum%3==0){
count+=a[0];
if(a[1]+a[2]==1)
count++;
}
else if(sum%3==1&&a[1]){
count++;
count+=a[0];
if(a[1]+a[2]==2)
count++;
}
else if(sum%3==2&&a[2]){
count++;
count+=a[0];
if(a[1]+a[2]==2)
count++;
}
if(count&1)
cout<<"S";
else
cout<<"T";
cout<<endl;
}
}
Comments
Post a Comment