hdu4662MU Puzzle

时间:2023-11-26 23:53:44

http://acm.hdu.edu.cn/showproblem.php?pid=4662

I+3*U模6为2或4的都可以 一个U相当于3个I  而I只能1-》2-》4-》8。。如此变换

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[];
int main()
{
int i,n;
cin>>n;
while(n--)
{
cin>>s;int a=,b=;
int k = strlen(s);
if(s[]!='M')
{
puts("No");
continue;
}
if(strcmp(s,"MI")==)
{
puts("Yes");
continue;
}
for(i = ; i < k ; i++)
if(s[i]=='I') a++;
else if(s[i]=='U') b++;
else break;
if(i!=k)
{
puts("No");
continue;
}
int s = a+b*;
if(s%==||s%==)
puts("Yes");
else
puts("No");
}
return ;
}