思路
模拟。
首先如果这个数是一位数肯定就输了,因此我们模拟即可。用一个 记录模拟次数,奇数小 S 赢,否则小 M 赢。
Code:
#include<bits/stdc++.h>
using namespace std;
int T;
signed main()
{
cin>>T;
while(T--)
{
int n,cnt=0;
cin>>n;
while(n>=10)
{
int x=n,sum=0;
while(x)
{
sum+=x%10;
x/=10;
}
n=sum;
cnt++;
}
if(cnt&1) cout<<"S\n";
else cout<<"M\n";
}
return 0;
}