1669:S-Nim

【输入样例】

2 2 5
3
2 5 12
3 2 4 7
4 2 3 7 12
5 1 2 3 4 5
3
2 5 12
3 2 4 7
4 2 3 7 12
0

【输出样例】

LWW
WWL

【提示】

数据范围与提示:

对于全部数据,0<n,m,k≤100,0<si,ai≤104 。

sol:模板,不解释

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=,B=;
int k,S[N],m,n,a[N];
int SG[B],Mark[B];
int main()
{
int i,j;
while(true)
{
R(k);
if(!k) break;
for(i=;i<=k;i++) R(S[i]);
sort(S+,S+k+);
SG[]=;
for(i=;i<=;i++)
{
for(j=;S[j]<=i&&j<=k;j++)
{
Mark[SG[i-S[j]]]=i;
}
for(j=;;j++) if(Mark[j]!=i)
{
SG[i]=j; break;
}
}
R(m);
while(m--)
{
R(n);
int ans=;
for(i=;i<=n;i++) ans^=SG[read()];
if(ans) putchar('W');
else putchar('L');
}
putchar('\n');
}
return ;
}
/*
input
2 2 5
3
2 5 12
3 2 4 7
4 2 3 7 12
5 1 2 3 4 5
3
2 5 12
3 2 4 7
4 2 3 7 12
0
output
LWW
WWL
*/

一本通1669S-Nim的更多相关文章

  1. [LeetCode] Nim Game 尼姆游戏

    You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...

  2. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  3. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  4. LeetCode 292. Nim Game

    Problem: You are playing the following Nim Game with your friend: There to stones. The one who remov ...

  5. 【SRM】518 Nim

    题意 \(K(1 \le K \le 10^9)\)堆石子,每堆石子个数不超过\(L(2 \le 50000)\),问Nim游戏中先手必败局面的数量,答案对\(10^9+7\)取模. 分析 容易得到\ ...

  6. HDU 2509 Nim博弈变形

    1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

  7. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

  8. Nim游戏

    目前有3堆石子,每堆石子个数也是任意的,双方轮流从中取出石子,规则如下:1)每一步应取走至少一枚石子:每一步只能从某一堆中取走部分或全部石子:2)如果谁不能取谁就失败. Bouton定理: 必败状态当 ...

  9. HDU 3032 Nim or not Nim (sg函数)

    加强版的NIM游戏,多了一个操作,可以将一堆石子分成两堆非空的. 数据范围太大,打出sg表后找规律. # include <cstdio> # include <cstring> ...

  10. 292. Nim Game

    292. Nim Game You are playing the following Nim Game with your friend: There is a heap of stones on ...

随机推荐

  1. CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置

    CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置 ========================================== ...

  2. POJ 1094 Sorting It All Out(拓扑排序+判环+拓扑路径唯一性确定)

    Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 39602   Accepted: 13 ...

  3. mysql的查询使用explain的讲解

    摘自:http://www.jb51.net/article/33736.htm 在 explain的帮助下,您就知道什么时候该给表添加索引,以使用索引来查找记录从而让select 运行更快.如果由于 ...

  4. static成员函数不能调用non-static成员函数

    1 一般类静态成员函数不能调用非静态成员函数 2 static成员函数可以调用构造函数吗? 答案是肯定的,由于static成员函数没有this指针,所以一般static成员函数是不能访问non-sta ...

  5. 20155233 《网络对抗技术》EXP3 免杀原理与实践

    正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion,自己利用shellcode编程等免杀工具或技巧 使用msf编码器生成jar包 输入命令msfvenom -p ...

  6. 20155304《网络对抗》Exp4 恶意代码分析

    20155304<网络对抗>Exp4 恶意代码分析 实践内容 1.系统运行监控 1.1使用schtasks指令监控系统运行 我们在C盘根目录下建立一个netstatlog.bat的文本文件 ...

  7. 20155325 Exp5 MSF基础应用

    目录 实验内容 遇到的问题 基础问题问答 老师!!!我实验三的C代码已经删除了,请求评分~~~ 实验内容 1.Windows服务渗透攻击--MS08-067 系统 虚拟机 参考博客 Windows X ...

  8. POJ2531&&1416&&2676&&1129

    搜索专题的最后一块了,也告别了这些老的东西了 接下来就是些全新的内容了啊! 这次的标签是简单搜索技巧和剪枝,也就是优化爆搜 当然,像Dancing links这样的玄学操作还是没有的 2531 题意: ...

  9. mfc Edit控件属性

    设置Edit控件属性 窗口创建顺序 初始化Edit控件数据 一.设置Edit控件属性 .Align Text :Right 二.窗口创建顺序 CMywindowdlg: 窗口构造函数 OnCreate ...

  10. Spring Boot (十五): Spring Boot + Jpa + Thymeleaf 增删改查示例

    这篇文章介绍如何使用 Jpa 和 Thymeleaf 做一个增删改查的示例. 先和大家聊聊我为什么喜欢写这种脚手架的项目,在我学习一门新技术的时候,总是想快速的搭建起一个 Demo 来试试它的效果,越 ...