HDU4662+无
把目標中的 U 轉化為 I。
又因為 I的個數是有規律的:1 2 4 8 16 。。。再結合可以取消 6 12 18 。。。個I。。。得解
?
#include<string.h> #include<stdio.h> #include<iostream> #include<algorithm> #include<map> using namespace std; const int maxn = 1000000+5; map<int,int>mp; void init(){mp.clear();int tt = 1;while( tt<maxn ){mp[ tt ] = 1;int tmp = tt;while( mp[tt]==1&&tmp>=6 ){mp[ tmp ] = 1;tmp -= 6;} tt *= 2; } } int main(){int n;init();scanf("%d",&n);while( n-- ){string s;cin>>s;int ans = 0;int len = s.size();int ans2 = 0;bool f = true;for( int i=1;i<len;i++ ){if( s[i]=='I' ){ans++;}else if( s[i]=='U' ){ans += 3;}else f = false ;}if( mp[ans]==1&&f==true&&s[0]=='M' ) puts("Yes");else puts("No");}return 0; }?
轉載于:https://www.cnblogs.com/pangblog/p/3265186.html
總結
- 上一篇: 怎样判别蓄电池的好坏?
- 下一篇: 最大公共子串提取“模式”