MU
来源:互联网 发布:2016qq红包钓鱼源码 编辑:程序博客网 时间:2024/06/11 10:03
Description
Suppose there are the symbols M, I, and U which can be combined to produce strings of symbols called words. We start with one word MI, and transform it to get a new word. In each step, we can use one of the following transformation rules
1. Double any string after the M (that is, change Mx, to Mxx). For example MIU to MIUIU.
2. Replace any III with a U. For example MUIIIU to MUUU.
3. Remove any UU. For example MUUU to MU.
Using these three rules is it possible to change MI into a given string in a finite number of stepsInput
First line, number of strings, n.
Following n lines, each line contains a nonempty string which consists only of letters 'M', 'I' and 'U'.
Total length of all strings = 106.Output
n lines, each line is 'Yes' or 'No'.Sample Input
2
MI
MUSample Output
Yes
No#include<string.h>#include<stdio.h>char s[1111111];int p[10]={0,1,1,0,1,0,0,0,1};int main(){ int ca,len,i,j,sum,flag; scanf("%d",&ca); while(ca--) { scanf("%s",s); len=strlen(s); sum=0; if(s[0]!='M') { printf("No\n"); continue; } if(s[0]=='M'&&s[1]=='I'&&len==2) { printf("Yes\n"); continue; } flag=0; for(i=0;i<len;i++) { if(s[i]=='M'&&i!=0) { puts("No"); flag=1; break; } if(s[i]=='I')sum+=1; else if(s[i]=='U')sum+=3; } if(flag==0) { while(sum>=9) { sum=(sum/9*3)+sum%9; } if(p[sum]==0)puts("No"); else puts("Yes"); } } return 0;}
- MU
- wordpress.mu
- 建mu服务器注意事项
- mstrong@sinotex.intnet.mu
- Mu 数据库分析!
- 转贴: MU渲染技术研究
- 基於單片機ATMEGA88PA-MU
- hdu 4662 MU Puzzle
- HDU 4662 MU Puzzle
- HDU 4662 MU Puzzle
- HDU-4662 MU puzzle
- HDU 4662 MU Puzzle
- hdu 4662 MU Puzzle
- hdu 4662 MU Puzzle
- C++函数mu模板
- xuan ze ping mu
- HDU 4662 MU Puzzle
- 寻人,“Mu中的滕堂静,~滕堂静~”
- iptable 命令
- Lottery
- 内核tcp的ack的处理
- const与类成员函数
- Eclipse快捷键大全(转载)
- MU
- Voice VLAN
- 内核tcp协议栈SACK的处理
- Linux下ssh登录速度慢的解决办法
- HDU-4638-Group
- linux 内核tcp拥塞处理(一)
- 在VBScript中,像C一样使用include一个.vbs脚本
- 倒排索引
- Flood