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");
    }
}


目录
相关文章
|
6月前
|
Java
HDU-2199-Can you solve this equation?
HDU-2199-Can you solve this equation?
37 0
|
6月前
|
Java
HDU-2199-Can you solve this equation
HDU-2199-Can you solve this equation
30 0
HDU-1097,A hard puzzle(快速幂)
HDU-1097,A hard puzzle(快速幂)
|
算法 Go
HDU-1548,A strange lift(Dijkstra)
HDU-1548,A strange lift(Dijkstra)
|
Java C语言
HDOJ/HDU 1029 Ignatius and the Princess IV(简单DP,排序)
HDOJ/HDU 1029 Ignatius and the Princess IV(简单DP,排序)
139 0
|
Go
HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)
HDOJ/HDU 1085 Holding Bin-Laden Captive!(非母函数求解)
107 0
|
存储 算法 测试技术