阅读694 返回首页    go 阿里云 go 技术社区[云栖]


hdu 4662 MU Puzzle 模拟

   模拟题,易知将所有U换成I,补全所有删去的U,应为2的幂,又因为每次删去2个U,即6个I,所以对6取模,发现余数只有2和4,所以如果余数为2,4则必为yes。

   注意开头不为M和中间有M的情况


/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define INF 1E9
using namespace std;
int main()
{
    int T;
    char s[1000005];
    scanf("%d",&T);
    while(T--)
    {
        scanf("%s",s);
        int i,j=0,len=strlen(s);
        if(s[0]=='M')
         for(i=1,j=0;i<len;i++)
         {
            if(s[i]=='U')
                j+=3;
            else if(s[i]=='I')j++;
            else {j=0;break;}
         }
        printf("%s\n",j%6!=2&&j%6!=4&&j!=1?"No":"Yes");
    }
}


最后更新:2017-04-03 15:21:43

  上一篇:go weblogic.xml在项目中设置的注意点
  下一篇:go Java面向对象基础--this关键字的解析