每次只能从取集合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. h5 中修改input中 placeholder的颜色

    input::-webkit-input-placeholder{ color:blue; } input::-moz-placeholder{ /* Mozilla Firefox 19+ */ c ...

  2. 小程序上拉触底&下拉加载

    data: { pageNo: 1,//当前页 pageSize: 10,//每页条数 count:'',//总条数 orderList: [], }, onLoad: function () { v ...

  3. Java自学-Lambda 聚合操作

    java 集合的聚合操作 步骤 1 : 传统方式与聚合操作方式遍历数据 遍历数据的传统方式就是使用for循环,然后条件判断,最后打印出满足条件的数据 for (Hero h : heros) { if ...

  4. 解决vue-cli使用组件报错

    今天使用vue-cli,明明写的没错,都是vue-cli自动生成的,编译时怎嘛就会报错呢? 报错信息如下: 浏览器端报错: Failed to compile. ./src/components/Hi ...

  5. jQuery---五角星评分案例

    五角星评分案例 1. 鼠标经过li的时候,当前的位置是实心五角星,前面的是实心.当前位置后面的是空心.注意此处不能完全用链式编程写到底 2. 鼠标离开,comment的所有孩子变为空心五角星.额外,找 ...

  6. 清北学堂—2020.1提高储备营—Day 2 morning(并查集、堆)

    qbxt Day 2 morning --2020.1.18 济南 主讲:李佳实 目录一览 1.并查集 2.堆 总知识点:基础数据结构 一.并查集 1.描述:并查集是一类十分常用的数据类型,它有着十分 ...

  7. hibernate报错:MappingException: Could not determine type for...解决办法

    有时候实体里的一些属性并不想映射到数据库(比方说子级菜单List), 如果不做处理的话会报字段映射错误找不到这列Column Not Found 例如:org.hibernate.MappingExc ...

  8. Uva1363(余数性质/减少枚举量)

    题意: 输入正整数n和k(范围均为1e9),求∑(k mod i),i从1~n 解法: 首先这道题直接暴力亲测会超时. 之后我们写几组数据之后可以发现当k/i的商相同的时候他们的余数成一个等差数列,而 ...

  9. 安装TensorFlow失败

    ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0 (from versions: non ...

  10. webpack4从安装到使用入过的那些坑

    1.全局安装 安装 webpack 前要确保已经下载 node.js 最新版本(node.js官网地址) 目前使用命令行安装的 webpack 默认为最新版本(以下我使用了全局安装.官网建议本地安装, ...