hdu4662MU Puzzle

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

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

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 char s[100010];
 7 int main()
 8 {
 9     int i,n;
10     cin>>n;
11     while(n--)
12     {
13         cin>>s;int a=0,b=0;
14         int k = strlen(s);
15         if(s[0]!='M')
16         {
17             puts("No");
18             continue;
19         }
20         if(strcmp(s,"MI")==0)
21         {
22             puts("Yes");
23             continue;
24         }
25         for(i = 1 ; i < k ; i++)
26         if(s[i]=='I') a++;
27         else if(s[i]=='U') b++;
28         else break;
29         if(i!=k)
30         {
31             puts("No");
32             continue;
33         }
34         int s = a+b*3;
35         if(s%6==2||s%6==4)
36         puts("Yes");
37         else
38         puts("No");
39     }
40     return 0;
41 }
View Code

 

转载于:https://www.cnblogs.com/shangyu/p/3247358.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值