牛客训练赛(博弈)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qkoqhh/article/details/82932629

先判一波有没有a-b的石子堆,有直接必胜。。

如果没有那么任何时候取完不能使石子数在a-b这个范围内,因此可以把a-b当成无用状态。。

然后直接打表就可以了。。

a=1的情况需要注意,因为 a>1的时候可以把b+1取到a以内,而a==1是不行的。。。(被这个卡到怀疑人生

/**
 *        ┏┓    ┏┓
 *        ┏┛┗━━━━━━━┛┗━━━┓
 *        ┃       ┃  
 *        ┃   ━    ┃
 *        ┃ >   < ┃
 *        ┃       ┃
 *        ┃... ⌒ ...  ┃
 *        ┃       ┃
 *        ┗━┓   ┏━┛
 *          ┃   ┃ Code is far away from bug with the animal protecting          
 *          ┃   ┃   神兽保佑,代码无bug
 *          ┃   ┃           
 *          ┃   ┃        
 *          ┃   ┃
 *          ┃   ┃           
 *          ┃   ┗━━━┓
 *          ┃       ┣┓
 *          ┃       ┏┛
 *          ┗┓┓┏━┳┓┏┛
 *           ┃┫┫ ┃┫┫
 *           ┗┻┛ ┗┻┛
 */ 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<stdlib.h>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 300005 
#define nm 600005
#define pi 3.1415926535897931
const int inf=1e9+7;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar() ;
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}




ll n,a,b,s,_x;
bool f;


ll sg(ll x){
    x%=b+a;
    if(a==1)return x;
    if(x<a)return 0;
    if(x>=b)return 1;
    return x/a+1;
}

int main(){
    int _=read();while(_--){
	f=false;s=0;
	n=read();a=read();b=read();
	inc(i,1,n){
	    _x=read();
	    if(a<=_x&&_x<=b)f=true;
	    s^=sg(_x);
	}
	puts(f||s?"Yes":"No");
    }
    return 0;
}

链接:https://www.nowcoder.com/acm/contest/203/G
来源:牛客网
 

Stones

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 524288K,其他语言1048576K
64bit IO Format: %lld

题目描述

有n堆石子,第i堆石子有xi个。
修修和栋栋轮流取石子,每人每次需要从任意一堆石子中取走个,修修先手。无法操作的人失败。此外,如果一个人取完了一堆石子,他会立即获胜。
不巧的是,修修除了数数以外啥都不会,他希望你帮他求出他能否获胜。

输入描述:

第一行一个整数t表示数据组数 (1 ≤ t ≤ 1000)。
每组数据第一行三个整数n,a,b (1 ≤ n ≤ 1000,1≤ a ≤ b ≤ 109),第二行n个整数 (1 ≤ xi ≤ 109)。

输出描述:

每组数据输出一行一个字符串:如果修修可以获胜输出Yes,否则输出No。

示例1

输入

复制

2
1 1 3
4
1 1 3
6

输出

复制

No
Yes

猜你喜欢

转载自blog.csdn.net/qkoqhh/article/details/82932629