#include<bits/stdc++.h>
using namespace std;
int f[1007],SG[1007],S[1007];//f为可以选取的石头个数,SG为sg函数,S为后继状态的集合
int n,l,r;       
int cnt=0;
void getSG(int n){//SG函数打表
      int i,j;
      memset(SG,0,sizeof(SG));
      for(i = 1; i <= n; i++){
         memset(S,0,sizeof(S));
         for(j = 0; f[j] <= i && j < cnt; j++)
             S[SG[i-f[j]]] = 1;
         for(j = 0;;j++) if(!S[j]){
             SG[i] = j;
             //printf("%d ",SG[i]);
             break;
         }
     }
 }
int nim(int x){
    if(x<l)
        return 0;//无用,都拿不了
    if(l==1)//打表得到的坑点
        return x%(r+l);
    else{//其余可总结出规律
        x-=r;
        x%=(l+r);
        x/=l;
        if(!x)
            return 1;
        else if(x==1)
            return 0;
        else
            return x;
    }
}
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&l,&r);
        //for(int k=l;k<=r;k++)
            //f[cnt++]=k;//将可选取的f数组构建
        int y;
        int ans=0;
        int flag=0;
        //getSG(1000);
        for(int i=1;i<=n;i++){
            scanf("%d",&y);
            if(y>=l&&y<=r)
                flag=1;
            ans^=nim(y);//nim游戏规律
        }
        puts(ans||flag?"Yes":"No");
    }
    return 0;
}

UPCOJ9526(SG函数打表,nim游戏异或规则)的更多相关文章

  1. Nowcoder 挑战赛23 B 游戏 ( NIM博弈、SG函数打表 )

    题目链接 题意 : 中文题.点链接 分析 : 前置技能是 SG 函数.NIM博弈变形 每次可取石子是约数的情况下.那么就要打出 SG 函数 才可以去通过异或操作判断一个局面的胜负 打 SG 函数的时候 ...

  2. 51 nod1067 Bash游戏 V2(sg函数打表)

    1067 Bash游戏 V2 1.0 秒 131,072.0 KB 5 分 1级题   有一堆石子共有N个.A B两个人轮流拿,A先拿.每次只能拿1,3,4颗,拿到最后1颗石子的人获胜.假设A B都非 ...

  3. hdu 2147 SG函数打表(手写也可以) 找规律

    kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others) Total ...

  4. bzoj 1228 [SDOI2009]E&D SG函数打表 找规律

    题目链接 Description 桌子上有2n 堆石子,编号为1..2n.将第2k-1 堆与第2k 堆(1 ≤ k ≤ n)为同一组.第i堆的石子个数用一个正整数Si表示.一次分割操作指的是,从桌子上 ...

  5. hdu1848(sg函数打表)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 题意:中文题诶- 思路:直接sg函数打表就好了 代码: #include <iostrea ...

  6. Educational Codeforces Round 68 (Rated for Div. 2)D(SG函数打表,找规律)

    #include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while ...

  7. bzoj 3105: [cqoi2013]新Nim游戏 异或高消 && 拟阵

    3105: [cqoi2013]新Nim游戏 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 535  Solved: 317[Submit][Stat ...

  8. LightOJ 1229 Treblecross(SG函数打表 + 遍历)题解

    题意:给你一串含“.”和“X”的字串,每次一个玩家可以把‘."变成“X”,谁先弄到三个XXX就赢.假如先手必赢,输出所有能必赢的第一步,否则输出0. 思路:显然如果一个X周围两格有X那么肯定 ...

  9. hdu 3032 Nim or not Nim? (sg函数打表找规律)

    题意:有N堆石子,每堆有s[i]个,Alice和Bob两人轮流取石子,可以从一堆中取任意多的石子,也可以把一堆石子分成两小堆 Alice先取,问谁能获胜 思路:首先观察这道题的数据范围  1 ≤ N ...

随机推荐

  1. CSS3 3D立体柜子实现

    1. [图片] 20140811233657.jpg 2. [图片] 120140811233846.jpg ​3. [代码][CSS]代码 body {      background-color: ...

  2. 1.angular js 学习网址

    双向数据绑定: http://html-js.com/article/1863

  3. django 使用内建过滤器实现文章摘要效果

    django 使用内建过滤器实现文章摘要效果 前端html代码 <div class="list-group"> {% if articles %} {% for ar ...

  4. RadioButton控件选中、取消

    js: var flag = true; function chkRadio(id) { id.checked = flag; flag = !flag; } aspx.cs: this.rbtKey ...

  5. raspi-config Expand root partition to fill SD card 原理

    /********************************************************************************** * raspi-config E ...

  6. bzoj 1006: 神奇的国度 MCS

    题目大意: 弦图的最小染色. 题解: 裸题. #include <vector> #include <cstdio> #include <cstring> #inc ...

  7. 【LeetCode】019. Remove Nth Node From End of List

    Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...

  8. POJ3784:Running Median

    浅谈堆:https://www.cnblogs.com/AKMer/p/10284629.html 题目传送门:http://poj.org/problem?id=3784 用一个"对顶堆& ...

  9. pip3 更改安装源

    经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的 ...

  10. MySQL复制--最快的从库搭建方法(tar包) -转

    最快的从库搭建方法0,准备从库第一次数据备份,临时锁所有表开启窗口1 mysql> flush tables with read lock; Query OK, 0 rows affected  ...