HDU-4662 MU Puzzle 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4662
倒推考虑长度就可以了。
//STATUS:C++_AC_31MS_240KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef __int64 LL;
typedef unsigned __int64 ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD= ,STA=;
const LL LNF=1LL<<;
const double EPS=1e-;
const double OO=1e30;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End char s[N];
int T; int main(){
// freopen("in.txt","r",stdin);
int i,j,cnt,len,ok;
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
len=strlen(s);
if(s[]!='M'){
printf("No\n");
continue;
}
cnt=;ok=;
for(i=;i<len;i++){
if(s[i]=='I')cnt++;
else if(s[i]=='U')cnt+=;
else {ok=;break;}
}
if(ok && (cnt%== || cnt%== || cnt==)){
printf("Yes\n");
}
else printf("No\n");
}
return ;
}
HDU-4662 MU Puzzle 水题的更多相关文章
- hdu 4662 MU Puzzle
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4662 MU Puzzle Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 4662 MU Puzzle (2013多校6 1008 水题)
MU Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 4662 MU Puzzle 数论或者水题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4662 题目是问目标串能否由MI得到,我们可以逆向思维,目标串能否反过来处理得到MI,所以,首先排除M ...
- HDU 4662 MU Puzzle:找规律
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4662 题意: 初始字符串为"MI". 有三个操作: (1)将'M'之后的所有字符翻 ...
- 【找规律】HDU 4662——MU Puzzle
来源:点击打开链接 这个题目的来源是人工智能领域MU猜想.比赛的时候也参考了相关资料,可是最后差一点没有把规律推出来. 注意到以下几个性质.第一,MI怎么变换M永远只能在第一位.第二,因为变换时只能在 ...
- HDU 4662 MU Puzzle(找规律)
题意:问是否能把MI通过以下规则转换成给定的字符串s. 1.使M之后的任何字符串加倍(即,将Mx更改为Mxx). 例如:MIU到MIUIU.2.用U替换任何III.例如:MUIIIU至MUUU.3.去 ...
- HDU 4662 MU Puzzle 简单找规律
没有任何变换(III变U和删UU操作)之前,I 的个数一定是2^x个(也就是2的整数次幂) 若仅考虑III变U,那么设U的个数为k,I 的个数变为2^x-3*k 再加上删除UU操作,假设我们删除了2* ...
- HDU 4662 MU Puzzle 2013 Multi-University Training Contest 6
现在有一个字符串"MI",这个字符串可以遵循以下规则进行转换: 1.Mx 可以转换成 Mxx ,即 M 之后的所有字符全部复制一遍(MUI –> MUIUI) 2.III 可 ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
随机推荐
- uva 825
这个......小学生就会的 坑在输入输出了 两个数之间可能不止一个空格....wa了好几遍啊 #include <cstdio> #include <cstring> # ...
- Samza文档翻译 : Concepts
此页介绍啊Samza的一些高层级概念. Streams Samza处理Streams(流).流由同一类型的不可变的消息组成.例如,一个流可以是对一个网站的所有点击,或者对一个数据库表的所有更新,或者一 ...
- 让wordpress分类和标签的描述支持HTML代码
默认 WordPress 后台分类和标签的编辑页面,分类和标签的描述是不支持 HTML 代码的,我们可以通过在当前主题的 functions.php 文件添加如下代码让分类和标签的描述支持 HTML ...
- 双十一运维怎么过,OneAPM 帮你救火,轻松运维
一年一度的双十一来了 有人剁手买买买,有人愁眉苦脸抱着服务器哭 对,说的就是你,汪 苦逼的运维工程师双十一怎么过来的? 守着电脑看预警还是通宵加服务器扩容 还是帮女朋友守着购物车等着一键清空 或者 今 ...
- express 3.0.x 中默认不支持layout.ejs的解决方法
1.第一种方法用include 用<% include 模板名(可不加.ejs) %>的写法,具体如下 <% include header %> //套用布局拆成两部分 hea ...
- Connect to the mysql dataase from remote server
Make sure that the firewall is closed!!!!!!!!! shell command should be like is: mysql -u username -p ...
- Android 国际化文字
本例演示中英文切换 在resource文件夹添加values-zh,这个文件夹对应中文环境的values文件夹,然后添加strings.xml: <?xml version="1.0& ...
- java使用redis
1.redis和memecache这种缓存框架,都分为服务器端和客户端. 我们在项目中使用,相当于客户端,要引入客户端使用redis的jar包 首先你需要下载驱动包,下载 jedis.jar,确保下载 ...
- java中dao层和service层的区别是什么?
首先解释面上意思,service是业务层,dao是数据访问层.呵呵,这个问题我曾经也有过,记得以前刚学编程的时候,都是在service里直接调用dao,service里面就new一个dao类对象,调用 ...
- Sequel Pro 免费的MySQL管理客戶端(有SSH部分)
官方站點:http://www.sequelpro.com Sequel Pro 的原名是 CocoaMySQL,是一个与 phpMyAdmin 類似的 MySQL 管理工具.它是由 Cocoa 和面 ...