#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
最新推荐文章于 2021-07-24 02:50:00 发布
本文深入探讨了代码逻辑分析及算法应用的核心概念,通过实例展示了如何利用算法解决实际问题,强调了理解代码逻辑和算法背后的思维方式对于提高编程能力的重要性。
528

被折叠的 条评论
为什么被折叠?



