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. Linux运维精华面试题

    1.什么是运维?什么是游戏运维? 1)运维是指大型组织已经建立好的网络软硬件的维护,就是要保证业务的上线与运作的正常,在他运转的过程中,对他进行维护,他集合了网络.系统.数据库.开发.安全.监控于一身 ...

  2. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录

    CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录: 0.Windows 10本机下载Xshell,以方便往Linux主机上上传大文件 1.CentOS7+CDH5.14.0安 ...

  3. C++实现词法分析器

    #include <iostream> #include <stdlib.h> #include <stdio.h> using namespace std; ]= ...

  4. MySQL 的几种进入方式

    对于码农一族来说,新入手电脑后,工具安装,环境搭建是为必备功课.环境搭不好工具装不全,后续的工作开展那就会有相当多的痛点,也会耗去相当多的时间和精力.近日,博主在安装 Mysql 数据库的过程中,一番 ...

  5. Vue中 $ref 的用法

    说明:vm.$refs 一个对象,持有已注册过 ref 的所有子组件(或HTML元素)使用:在 HTML元素 中,添加ref属性,然后在JS中通过vm.$refs.属性来获取注意:如果获取的是一个子组 ...

  6. fmt.printf输出的格式

    动 词 功 能 %v 按值的本来值输出 %+v 在 %v 基础上,对结构体字段名和值进行展开 %#v 输出 Go 语言语法格式的值 %T 输出 Go 语言语法格式的类型和值 %% 输出 % 本体 %b ...

  7. token回话保持,axios请求拦截和导航守卫以及token过期处理

    1:了解token:有时候大家又说token令牌.整个机制是前端第一次登陆发送请求,后端会根据前端的用户名和密码, 通过一些列的算法的到一个token令牌, 这个令牌是独一无二的,前端每次发送请求都需 ...

  8. day 8:open文件和with的使用

    本节内容: 1,open打开文件后的几种操作 2,with和open的连用 3,flush的使用 1:open 1)r权限 f = open("D:\\auto\project\\fulls ...

  9. 在IE浏览器进行编辑操作再展示出现乱码问题

    解决方法: ajax传输数据时进行encodeURI编码就可以了 例如: 在其他浏览器中没有进行 encodeURI 直接传输,无问题. 然而,在IE10 和11中进行下面这段代码编辑后,再展示出来就 ...

  10. 【转】一个 Linux 上分析死锁的简单方法

    简介 死锁 (deallocks): 是指两个或两个以上的进程(线程)在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这 ...