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-cli中配置vuex流程和注意事项
本文目录 vue-cli下新建站 配置路由更改HelloWorld.vue组件到新建Home.vue组件 安装vuex 测试是否安装成功vuex一:vue-cli下新建站 a)新建文件夹vuexStu ...
- 解决jQuery中input 失去焦点之后,不能再获取到焦点
//编辑过敏史 if(iToolbar == 'editGMS'){ lstype="gms"; var gms=""; if(gmstype=="0 ...
- C# Winform初体验
设计一个简单的登录窗口,要求输入用户名:小金,密码:123456时候点登录能正确转到另一个窗口. 1.建立窗体应用. 2.这里创建一个login和一个NewForm的窗体. 3.在login的窗体拖拉 ...
- 浏览器对象模型“BOM”-- window对象
global对象 全局对象 所有的全局变量和全局方法,都可以归在window上 <!DOCTYPE html> <html lang="en"> <h ...
- 初识Socket通讯编程(一)
一.什么是socket? 当两台计算机需要通信的时候,往往我们使用的都是TCP去实现的,但是并不会直接去操作TCP协议,通常是通过Socket进行tcp通信.Socket是操作系统提供给开发者的一个接 ...
- [Python]scatter_matrix报错 module 'pandas' has no attribute 'scatter_matrix'
运行pandas.scatter_matrix()散点图函数时报错, 原因是该函数在新版本用法发生了变化: pandas.plotting.scatter_matrix 完整用法:pd.plottin ...
- JSP页面取不到ModelAndView里面存的值
方法1:在jsp页面上加上<%@ page isELIgnored="false" %>
- HTML5存储(带一个粗糙的打怪小游戏案例)
本地存储localStorage设置存储内容setItem(key,value) localStorage.setItem('leo','23'); 更新存储内容对象[key]=value对象.key ...
- win下的终端使用指南
win下的终端使用指南 win 下的命令行工具是真的难用 . 具体的难用就不形容了 . 有了 PowerShell 也没觉得好用 . 还是喜欢Linux的终端,及Bash命令. 替换方案 比较好的替换 ...
- linux服务基础之编译安装nginx
nginx源码下载地址: http://nginx.org/download/nginx-1.16.0.tar.gz //根据需要下载其他版本 1. 下载nginx # wget http://ngi ...