C++-POJ2960-S-Nim-[限制型Nim]
每次只能从取集合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]的更多相关文章
- HDU 5795 A Simple Nim(简单Nim)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
Nim or not Nim? Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- 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 ...
- 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 ...
- 【HDU3032】Nim or not Nim?(博弈论)
[HDU3032]Nim or not Nim?(博弈论) 题面 HDU 题解 \(Multi-SG\)模板题 #include<iostream> #include<cstdio& ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 折腾vue--环境搭建(一)
1.安装nodejs nodejs下载地址:https://nodejs.org/en/ 2.检测nodejs //检测nodejs版本 node -v //检测npm npm –v 3.安装vue ...
- springBoot 中 logback配置文件详解
logback介绍和配置详解 logback是Java的开源框架,性能比log4j要好.是springboot自带的日志框架.该框架主要有3个模块: logback-core:核心代码块(不介绍) l ...
- 简述react、redux、react-redux、redux-saga、dva之间的关系
[react] 定位:React 是一个用于构建用户界面的JavaScript库. 特点:它采用声明范式来描述应用,建立虚拟dom,支持JSX语法,通过react构建组件,能够很好的去复用代码: 缺点 ...
- openssl CVE-2016-2107 漏洞检测
最近在安装python3 时升级openssl 版本,在摸索openssl 升级过程中才发现centos6 默认安装的openssl 1.0.1e 版本是有一个严重的漏洞的(Padding oracl ...
- (办公)记事本_Linux查找命令
参考谷粒学院的linux视频教程:http://www.gulixueyuan.com/course/300/task/7091/show 搜索命令 .whereis命令: 1.1.Linux whe ...
- session 控制
session 控制 beego 内置了 session 模块,目前 session 模块支持的后端引擎包括 memory.cookie.file.mysql.redis.couchbase.memc ...
- Picture POJ - 1177 线段树+离散化+扫描线 求交叉图像周长
参考 https://www.cnblogs.com/null00/archive/2012/04/22/2464876.html #include <stdio.h> #include ...
- canvas手势解锁源码
先放图 demo.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- css样式-区域内文字不会被选中
要注意浏览器的兼容性: -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none;
- Linux学习笔记:磁盘分区
本文更新于2019-12-30.操作系统为Debian 8.9 (jessie). 以下假设新磁盘为/dev/sdb,要创建一个分区/dev/sdb1,文件系统类型为xfs.请根据实际情况,自行选择. ...