#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 ...
随机推荐
- 使用Java线程同步工具类CountDownLatch
java.util.concurrent.CountDownLatch是Java并发并发编程中的线程同步工具类,基于AQS(java.util.concurrent.locks.AbstractQue ...
- 2021-10-25 css中零值0后面是否要省略单位
原理 在css中如果值为0,可以省略单位. 在css应用场景中,有可能是多端多人维护.即可能维护的人有A及B及C-,应用场景中有电脑端及手机端及小程序及打印机之类的. 结论 个人认为不要省略单位,不要 ...
- Mac环境下, VMware Fusion Pro下的虚拟机( CentOS 7)的 NAT网络配置
前提实现说明 1.vm版本VMware Fusion Pro 12.1.0 2.centos版本centos7.6 1.虚拟机能访问外网,虚拟机能访问mac本机: 2.mac本机可以连接虚拟机 操作步 ...
- C C++结构体四种方式
第一种语法表示 struct 结构体名称 { 数据类型 member1: 数据类型 member2; }; #include<iostream> using names ...
- elasticsearch 查询索引和清理索引命令
查询 curl --silent 'http://127.0.0.1:9200/_cat/indices' 删除 curl -X DELETE "localhost:9200/wifiloc ...
- 【Azure 事件中心】Spring Boot 集成 Event Hub(azure-spring-cloud-stream-binder-eventhubs)指定Partition Key有异常消息
问题描述 在Spring Boot应用中集成Event Hub,发送消息时指定Partition Key,日志中发现异常: 应用使用Event Hub版本为 <dependency> &l ...
- linux基本知识汇总2(系统编程) 60000字汇总
/////////////进程/任务 -- task任何启动并运行程序的行为,都是由操作系统帮助我们将程序转换成进程 -- 进程:完成特定的任务 进程控制块:PCB(win) / task_struc ...
- Python实现snap:对齐多张遥感影像的空间范围
本文介绍基于Python中ArcPy模块,实现基于栅格图像批量裁剪栅格图像,同时对齐各个栅格图像的空间范围,统一其各自行数与列数的方法. 首先明确一下我们的需求.现有某一地区的多张栅格遥感影像 ...
- 九: Mysql逻辑架构
# 逻辑架构 1. 服务器处理客户端请求 首先MySQL是典型的C/S架构,即Client/Server架构,服务器端程序使用的mysqld· 不论客户端进程和服务器进程是采用哪种方式进行通信,最后实 ...
- harbor 安装
下载地址: https://github.com/goharbor/harbor/releases?page=1 下载了多个版本,发现仅v1.10.17版本支持GC清理,所以这里安装的v1.10.17 ...