每次只能从取集合S中个数的物品,其他和普通Nim游戏相同

预处理出每种物品堆的sg值,然后直接xor一下,xor-sum>0即必胜

 #include <set>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 10001
int k,m,l,s[],sg[N],vis[N],ans,a;
int main(){
while(scanf("%d",&k)&&k){
for (int i=;i<=k;i++)scanf("%d",&s[i]);
sort(s+,s+k+);
memset(sg,,sizeof(sg));//sg[0]=0;
for(int i=;i<N;i++){
memset(vis,,sizeof(vis));
for(int j=;j<=k&&s[j]<=i;j++)vis[sg[i-s[j]]]=;
for(int j=;;j++)if(!vis[j]){sg[i]=j;break;}
}
for(scanf("%d",&m);m--;){
for(ans=,scanf("%d",&l);l--;)scanf("%d",&a),ans^=sg[a];
putchar(ans?'W':'L');
}
puts("");
}
return ;
}

C++-POJ2960-S-Nim-[限制型Nim]的更多相关文章

  1. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  3. HDU 3032 Nim or not Nim? (sg函数求解)

    Nim or not Nim? Problem Description Nim is a two-player mathematic game of strategy in which players ...

  4. Nim or not Nim? hdu3032 SG值打表找规律

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  5. 【HDU3032】Nim or not Nim?(博弈论)

    [HDU3032]Nim or not Nim?(博弈论) 题面 HDU 题解 \(Multi-SG\)模板题 #include<iostream> #include<cstdio& ...

  6. HDU 3032 Nim or not Nim? (sg函数)

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  7. hdu 3032 Nim or not Nim? sg函数 难度:0

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. HDU 3032 Nim or not Nim?(博弈,SG打表找规律)

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  9. HDU 3032 Nim or not Nim?(Multi_SG,打表找规律)

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  10. HDU3032 Nim or not Nim?(Lasker’s Nim游戏)

    Nim or not Nim? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

随机推荐

  1. 回炉重造之重读Windows核心编程-004-进程

    进程是一个正在运行的程序的实例,由内核对象和地址空间组成.进程是不活泼的,执行地址空间中代码的是在它的环境中运行线程.每个线程都需要自己的一组CPU寄存器和堆栈. 为了让所有线程都能运行,操作系统就要 ...

  2. 解决session共享问题

    方法一 使用Nginx让它绑定ip(没有共享所以就没有共享问题了) 配置Nginx upstream backserver { ip_hash; server localhost:8080; serv ...

  3. 关于javascript中的内置函数

    (1) parseInt()函数 语法:parseInt(string,[n])   该函数主要将首位为数字的字符串转化为数字,若该字符串不是以数字开头,则返回NaN; n是用于指出字符串中的数据是几 ...

  4. Git 尝试

    1,下载Git 2,安装GIt 3,config : git config --global user.name "mxb" git config --global user.em ...

  5. python类详细说明、常用内置方法和self的作用

    一.类的定义 在Python中,一切皆对象,即便是类本身,也是一种type类型的特殊对象. class Person: def __init__(self, name, age): self.name ...

  6. Java中Thread方法启动线程

    public class ThreadTest extends Thread {  private int count = 10; @Override public void run() { //重写 ...

  7. opencv —— createTrackbar、getTrackbarPos 滑动条的创建和使用

    创建滑动条:createTrackbar 函数 createTrackbar 函数用于创建一个可以调整数值的滑动条,并将滑动条附加在指定的窗口上. int createTrackbar(const s ...

  8. element使用

    官方网址: 点击 全局使用 1.创建项目 vue init webpack vue-ele 配置 2.安装依赖 npm install 3.安装loader模块(开发) npm install sty ...

  9. Origin-作图相关

    1.跨越缺失数据连接直线

  10. PHP0010:PHP操作mysql

    cmd中清除之前的记录 cmd操作数据库的步骤: php 到 mysql的并发数 15个左右 for循环是要知道起点和终点 foreach是从结果集中取数据 而while可遍历自然结果集