传送门

题意:

nim游戏,多了一种操作:将一堆分成两堆


Multi-SG游戏规定,在符合拓扑原则的前提下,一个单一游戏的后继可以为多个单一游戏。

仍然可以使用$SG$函数,分成多个游戏的后继$SG$值为多个游戏的异或和

然后本题规模很大,手动打一下表,发现$\mod 4=3$ 时$sg(x)=x+1$,$\mod 4=0$ 时$sg(x)=x-1$,其他不变

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=1e6;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int n;
inline int cal(int a){
int t=a%;
return t== ? a- : (t== ? a+ : a);
}
int main(){
freopen("in","r",stdin);
int T=read();
while(T--){
n=read();
int sg=;
for(int i=;i<=n;i++) sg^=cal(read());
if(sg) puts("Alice");
else puts("Bob");
}
}

HDU 3032 Nim or not Nim? [Multi-SG]的更多相关文章

  1. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 【hdu 3032】Nim or not Nim?

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  7. 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 ...

  8. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  9. HDU 3094 树上删边 NIM变形

    基本的树上删边游戏 写过很多遍了 /** @Date : 2017-10-13 18:19:37 * @FileName: HDU 3094 树上删边 NIM变形.cpp * @Platform: W ...

  10. 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 ...

随机推荐

  1. POJ_2769同余问题

    Reduced ID Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9310   Accepted: 374 ...

  2. node中定时器, process.nextTick(), setImediate()的区别与联系

    1.定时器 setTimeout()和setInterval()与浏览器中的API是一致的,定时器的问题在于,他并非精确的(在容忍范围内).尽管事件循环十分快,但是如果某一次循环占用的时间较多,那么下 ...

  3. GBK,UTF8是什么?有什么区别,做网站选择哪种好?

    GBK包含全部中文字符: UTF-8则包含全世界所有国家需要用到的字符. GBK是在国家标准GB2312基础上扩容后兼容GB2312的标准(好像还不是国家标准) UTF-8编码的文字可以在各国各种支持 ...

  4. win7、win10进程pid4占用80端口的解决办法

    https://jingyan.baidu.com/article/7e4409533ffe092fc1e2ef10.html 今天想用wamp架设服务器,但是程序启动不起来,查看系统端口,80端口被 ...

  5. phpcms v9——工作需要【套模板】

    phpcms v9 模板标签说明整理 作者:匿名 来源:ChinaZ源码报导 浏览:44061次 2011-6-17 15:52:09 字号:大 中 小 [摘要]本文介绍phpcms v9中模板标签使 ...

  6. CSS容器属性

    最近一直想美化博客的文字效果和增加文章末尾的转发提示,所以这两天抽空研究了一下CSS,前两篇可以翻我的博客,今天写的这篇是介绍增加文章末尾的转发提示,效果如文章末尾所示,好了,CSS很简单,我就不介绍 ...

  7. 【开发技术】 B/S、C/S的区别

    c/s     客户端----服务器端             可以用譬如vb或vc等语言开发,比如最常用的oicq就是.   需要在客户端安装软件. b/s     浏览器端----服务器端     ...

  8. 浅谈linux虚拟内存结构

    一个虚拟存储器系统要求硬件和软件之间紧密写作(mmu(内存管理单元,虚拟地址到物理地址的翻译),TLB块表(虚拟地址到物理地址index,虚拟寻址),l1,l2,l3高速缓存(物理单元数据)物理寻址) ...

  9. 深入剖析Java编程中的中文问题及建议最优解决方法

    摘录自:http://fafeng.blogbus.com/logs/3062998.html http://www.blogbus.com/fafeng-logs/3063006.html 深入剖析 ...

  10. ETL工具--kettle篇(17.10.09更新)

    ETL是EXTRACT(抽取).TRANSFORM(转换).LOAD(加载)的简称,实现数据从多个异构数据源加载到数据库或其他目标地址,是数据仓库建设和维护中的重要一环也是工作量较大的一块.当前知道的 ...