A

题意:给你n根棍子,两个人每次拿m根你,你先拿,如果该谁拿的时候棍子数<m,这人就输,对手就赢,问你第一个拿的人能赢吗

代码:

#include<stdio.h>
#define ll long long
using namespace std;
ll n,m;
int main()
{
while(~scanf("%I64d%I64d",&n,&m))
{
ll r=n/m;
if(r%2==1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

B:字符串,暴力

题意:给你的第一串里的字符都是好的,除开这个字符以外的所有小写字符都是坏了,然后再给你一个待匹配的的串,这个串中的’?‘可以替换成任何一个好的小写字符,‘*’表示可以替换成一个空的字符串或是一个全部由坏的小写字符组成的字符串(长度可以为1,也可以大于1)。然后下面开始询问,输入一个串问能不能由上面的串得来,可以就输出YES,否则输出NO

几组样例吧

abc

a*?b

3

acb

YES

aicb

YES

ab

NO

k

aaa

1

aa

NO

这个题有个bug我觉得因为对于下面的数据

a

*?

2

a

NO

ba

NO

这里应该都输出YES才对,但是我的代码在codeforces上过了,应该第二个字符串必须包含小写字符吧。

代码:

#include<stdio.h>
#include<string.h>
using namespace std;
char a[30];
int vis[30];
char b[111000];
int n;
char c[111000];
int main()
{
while(~scanf("%s",a))
{
memset(vis,0,sizeof(vis));
for(int i=0; a[i]; i++)
vis[a[i]-'a']=1;
scanf("%s",b);
scanf("%d",&n);
int ans=0;
for(int i=0;b[i];i++)
if(b[i]=='*')
ans++;
for(int l=0; l<n; l++)
{
int flag=0;
scanf("%s",c);
int x=strlen(b);
int y=strlen(c);
int i=0,j=0;
if(ans==0&&y!=x)
flag=1;
if(ans==1&&y<x-1)
flag=1;
else
while(i<x&&j<y)
{
if(b[i]==c[j])
{
i++;
j++;
continue;
}
else if(b[i]=='?')
{
if(vis[c[j]-'a']==0)
{
flag=1;
break;
}
else
{
i++;
j++;
continue;
}
}
else if(b[i]=='*')
{
if(y==x-1)
{
i++;
continue;
}
else
{
for(int k=j; k<=j+y-x; k++)
{
if(vis[c[k]-'a']==1)
{
flag=1;
break;
}
}
if(flag==1)
break;
i++;
j=j+y-x+1;
}
}
else
{
flag=1;
break;
}
}
if(flag==1)
printf("NO\n");
else
printf("YES\n");
}
}
return 0;
}

Codeforces Round #425 (Div. 2)的更多相关文章

  1. Codeforces Round #425 (Div. 2)C

    题目连接:http://codeforces.com/contest/832/problem/C C. Strange Radiation time limit per test 3 seconds ...

  2. Codeforces Round #425 (Div. 2) Problem D Misha, Grisha and Underground (Codeforces 832D) - 树链剖分 - 树状数组

    Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations ...

  3. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  4. Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力

    It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...

  5. Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks (Codeforces 832A)

    It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day h ...

  6. Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)

    题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...

  7. Codeforces Round #425 (Div. 2))——A题&&B题&&D题

    A. Sasha and Sticks 题目链接:http://codeforces.com/contest/832/problem/A 题目意思:n个棍,双方每次取k个,取得多次数的人获胜,Sash ...

  8. Codeforces Round #425 (Div. 2) B - Petya and Exam

    地址:http://codeforces.com/contest/832/problem/B 题目: B. Petya and Exam time limit per test 2 seconds m ...

  9. Codeforces Round #425 (Div. 2) C - Strange Radiation

    地址:http://codeforces.com/contest/832/problem/C 题目: C. Strange Radiation time limit per test 3 second ...

随机推荐

  1. 去除web项目中的css、js缓存

    <link rel="stylesheet" type="text/css" href="~/Content/Home.css?param=Ma ...

  2. mysql explain执行详解

    1).id列数字越大越先执行,如果说数字一样大,那么就从上往下依次执行,id列为null的就表是这是一个结果集,不需要使用它来进行查询.2).select_type列常见的有:A:simple:表示不 ...

  3. pythone函数基础(14)发送邮件

    导入yagmail模块import yagmailusername='uitestp4p@163.com'password='houyafan123'#生成授权码,qq.163.126都是授权码 ma ...

  4. C# 线程获取/设置控件(TextBox)值

    线程读写控件需要用委托(delegate)与Invoke/BeginInvoke来进行 参考内容:http://www.cnblogs.com/runner/archive/2011/12/30/23 ...

  5. Jenkins+docker自动部署

    项目目录结构如下 对此项目,使用Jenkins构建dockers镜像 步骤如下: 1.安装Jenkins和docker,具体安装步骤,自行度娘把,在此不详述了. 2.Jenkins安装插件Gradle ...

  6. python 微信轰炸

    from __future__ import unicode_literals import requests import itchat import time def get_news(): ur ...

  7. openstack系列文章(1)devstack安装测试Queens

    1.在OpenStack 圈子中,有这么一句名言:”不要让朋友在生产环境中运行DevStack.但是初学者在没有掌握OpenStack CLI的情况下用devstack安装测试环境还是不错的.本系列文 ...

  8. js处理日期

    /Date(-62135596800000)/ 如何用js转化为日期时间格式 2015-11-20 14:33:20像这样 var a = '/Date(-62135596800000)/' Date ...

  9. 一张图说明TCP和UCP协议

    图片来自网络. 本来不想打字了,但是博客园有字数限制... 第一次 第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SENT状态,等待服务器确认:SYN:同步序列编号( ...

  10. Python json.dumps 自定义序列化操作

    def login_ajax(request): if request.method == "GET": return render(request, 'login_ajax.ht ...