#Multi-SG#HDU 3032 Nim or not Nim?
题目
有\(n\)堆石子,每次可以从一堆中取出若干个或是将一堆分成两堆非空的石子,
取完最后一颗石子获胜,问先手是否必胜
分析
它的后继还包含了分成两堆非空石子的SG函数,找规律可以发现
\]
判断\(n\)堆石子SG函数异或和不为0则先手必胜
代码
#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
typedef unsigned uit;
inline uit iut(){
rr uit ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
signed main(){
for (rr uit T=iut();T;--T){
rr uit ans=0;
for (rr uit n=iut();n;--n){
rr uit x=iut();
switch (x&3){
case 0:{
ans^=x-1;
break;
}
case 3:{
ans^=x+1;
break;
}
default:{
ans^=x;
break;
}
}
}
if (ans) puts("Alice");
else puts("Bob");
}
return 0;
}
#Multi-SG#HDU 3032 Nim or not Nim?的更多相关文章
- 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函数 难度: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? Problem Description Nim is a two-player mathematic game of strategy in which players ...
- 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打表找规律)
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 ...
- HDU 5795 A Simple Nim(简单Nim)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 3094 树上删边 NIM变形
基本的树上删边游戏 写过很多遍了 /** @Date : 2017-10-13 18:19:37 * @FileName: HDU 3094 树上删边 NIM变形.cpp * @Platform: W ...
- 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 ...
- HDU 3032 multi-sg 打表找规律
普通NIM规则加上一条可以分解为两堆,标准的Multi-SG游戏 一般Multi-SG就是根据拓扑图计算SG函数,这题打表后还能发现规律 sg(1)=1 sg(2)=2 sg(3)=mex{0,1,2 ...
随机推荐
- 非常好用的VS Code插件
Auto-Collapse Explorer 如果希望在VS Code编辑器中打开文件的时候自动展开对应的目录结构,需要开启"Auto Reveal". 具体设置步骤: 1.打开设 ...
- Redis居然还有比RDB和AOF更强大的持久化方式?
https://cloud.tencent.com/developer/article/1786055
- nuxt调用weixin-js-sdk
在nuxt中调用weixin-js-sdk与在vue中有所不同. 通常在vue中用 import wx from 'weixin-js-sdk' 调用weixin-js-sdk,但在nuxt中会出现w ...
- 如何在 WindowManager.addView 中使用 Jetpack Compose
如何在 WindowManager.addView 中使用 Jetpack Compose 一.引出问题 Android 开发中,很常见的一个场景,通过 WindowManager.addView() ...
- c# rdkafka 设置偏移量(offset)
参考资料: librdkafka: 如何设置Kafka消费者订阅消息的起始偏移位置 领导要求kafka消费者端消费最新的数据. 不知道怎么设置偏移量,查了资料. 用惯了封装好的东西,都不知道怎么设置了 ...
- MBD工具链的云部署
MBD工具链的云部署 "云技术永远不会用于汽车开发".说到云部署在汽车行业的应用,业界曾经认为云技术并不适合用在汽车行业的产品开发.知识产权保护.数据的安全.流程不够透明.迁移成本 ...
- Spring + JAX-WS : ‘xxx’ is an interface, and JAXB can’t handle interfaces 错误解决方法
错误栈 Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotatio ...
- 【Azure Developer】使用 Azure PowerShell 执行 Azure 表存储操作时遇见的4个问题
要使用PowerShell操作Azure的表存储,需要经过以下步骤: 1:必须安装 Az 和 AzTable 模块.安装命令为: #安装 Az 模块 Install-Module -Name Az - ...
- 主流开源分布式图计算框架 Benchmark
本文由美团 NLP 团队高辰.赵登昌撰写,首发于 Nebula Graph Community 公众号 前言 随着近年来数据的爆炸式增长,如何高效地分析处理数据,在业界一直备受关注.现实世界中的数据往 ...
- Java 多线程------创建多线程的方式二:实现 Runnable接口 + 比较创建线程的两种方式:
1 package com.bytezero.threadexer; 2 3 /** 4 * 5 * 创建多线程的方式二:实现 Runnable接口 6 * 1.创建一个实现了Runnable接口类 ...