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
*/

最新文章

  1. 炫酷的jQuery对话框插gDialog
  2. 1-MySQL命令行
  3. CE驱动动态加载卸载
  4. 实用手册:130+ 提高开发效率的 vim 常用命令
  5. Date and Time
  6. linux如何查进程、杀进程
  7. zoj 3822 Domination(2014牡丹江区域赛D称号)
  8. 【MySQL案件】ERROR 1665 (HY000)
  9. 转载–移动互联网终端的touch事件,touchstart, touchend, touchmove
  10. JavaWeb 后端 &lt;十&gt; 之 数据池 C3P0 DPCB JNDI
  11. 2 TileMapObject的使用
  12. [c/c++] programming之路(30)、位运算(一)
  13. 了解一下Ubuntu系统
  14. 2018-12-03 VS Code英汉词典插件v0.0.7-尝试词性搭配
  15. js有关事件驱动
  16. 【转】Asp.net实现URL重写
  17. JAVA统计中文的个数
  18. mybais 之parameterType =&quot;list&quot;
  19. [微信开发] - 使用weixin4j进行二次开发
  20. Android蓝牙——HID开发

热门文章

  1. PAT B1008 数组元素循环右移问题 (20 分)
  2. JAVA框架Struts2 Action类
  3. 树莓派学习笔记(5):成功实现NAS家庭服务器(流媒体播放、文件共享及下载机)
  4. 树莓派学习笔记(4):利用yeelink实现在线硬件状态监控
  5. Oracle 函数function之返回结果集
  6. 2017-2018-2 20155229《网络对抗技术》Exp1:逆向及Bof基础实践
  7. 2017-2018-2 《网络对抗技术》 20155310 第二周 Exp1 PC平台逆向破解(5)M
  8. Pick定理、欧拉公式和圆的反演
  9. SQLAlchemy 关联表删除实验
  10. Selenium-Switch与SelectApi接口详解