#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<queue>
const int N = 110000;
int hash[20];
int sum;
void init(char* str){
memset(hash,0,sizeof(hash));
sum=0;
for(int i=0;str[i];i++){
int x=str[i]-'0';
x%=3;
if(x==0)
x=3;
sum+=x;
hash[x]++;
}
}
void sol(char* str){
init(str);
int len=strlen(str);
if(len==1){
printf("S\n");
return ;
}
if(sum%3==0){
if(hash[3]%2==0)
printf("T\n");
else
printf("S\n");
}
else{
int x=sum%3;
if(hash[x]==0)
printf("T\n");
else{
if(hash[3]%2==0)
printf("S\n");
else
printf("T\n");
}
}
}
int main(){
int t;
char str[1050];
while(~scanf("%d",&t)){
for(int i=1;i<=t;i++){
scanf("%s",str);
printf("Case %d: ",i);
sol(str);
}
}
return 0;
}
UVA - 11489 Integer Game
最新推荐文章于 2018-11-13 22:07:45 发布