每日题解六(六)--咪咪游戏
咪咪游戏
https://ac.nowcoder.com/acm/contest/4911/A
题目问你是不是mqmqmq这种类型的字符串..方法很简单..输入下这个字符串然后判断下位数..奇数位必须是m,偶数位必须是q..
然后还要判断下最后一个字符是不是q..
代码如下:
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define inf 132913423039
typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+5;
const int M=1e6+5;
const double eps=1e-7;
using namespace std;
ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b) { return a*b/gcd(a,b); }
ll qp(ll a,ll b, ll p){ll ans = 1;while(b){if(b&1){ans = (ans*a)%p;--b;}a = (a*a)%p;b >>= 1;}return ans%p;}
ll Inv(ll x) { return qp(x,mod-2,mod);}
ll C(ll n,ll m){if (m>n) return 0;ll ans = 1;for (int i = 1; i <= m; ++i) ans=ans*Inv(i)%mod*(n-i+1)%mod;return ans%mod;}
int main()
{
ios;
int q;
cin>>q;
while(q--)
{
string s;
cin>>s;
int flag=1;
for(int i=0;i<s.size();i++)
{
if(i%2==0) {if(s[i]!='m') flag=0;}
else {if(s[i]!='q') flag=0;}
}
if(flag&&(s.size()%2==0)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
lpt的小屋 文章被收录于专栏
我想要一份甜甜的爱情
海康威视公司氛围 967人发布