[Algo Beat 009 & MROI-R1] Number Game
一道简单题。
思路
我们可以设
若输入的
证明
第
时间复杂度
AC Code
#include<bits/stdc++.h>
#define AC 0
using namespace std;
const int N=1e5+10;
const int M=1e4+10;
const int K=1e3+10;
const int MOD=1e9+7;
const int MOD2=998244353;
const int INF=-1e9;
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f3f3f;
typedef pair<int,int> PII;
int cnt2(ll x){
int s=0;
while(x>0){
s+=x%10;
x/=10;
}
return s;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while(t--){
ll n;
cin>>n;
int s=0;
while(n>=10){
n=cnt2(n);
s++;
}
if(s&1) cout<<"S"<<endl;
else cout<<"M"<<endl;
}
return AC;
}