HDU3032 Nim or not Nim?

解:使用sg函数打表发现规律,然后暴力异或起来即可。
#include <bits/stdc++.h> typedef long long LL;
const int N = ; int a[N]; inline LL sg(LL x) {
int t = x & ;
if(t == || t == ) return x;
if(t == ) return x + ;
return x - ;
} inline void solve() {
int n;
LL ans = ;
scanf("%d", &n);
for(int i = ; i <= n; i++) {
scanf("%d", &a[i]);
ans ^= sg(a[i]);
}
if(ans) {
printf("Alice\n");
}
else printf("Bob\n");
return;
} int main() {
int T;
scanf("%d", &T);
while(T--) solve();
return ;
}
AC代码
HDU3032 Nim or not Nim?的更多相关文章
- 【HDU3032】Nim or not Nim?(博弈论)
[HDU3032]Nim or not Nim?(博弈论) 题面 HDU 题解 \(Multi-SG\)模板题 #include<iostream> #include<cstdio& ...
- 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 ...
- HDU3032 Nim or not Nim?(Lasker’s Nim游戏)
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 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函数求解)
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函数 难度: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? 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 ...
随机推荐
- Visual Studio 2017调试开源项目代码
在我们的开发过程中很多时候我们会从GitHub上面下载一些开源的项目代码,然后在此基础上进行调试,正常情况下我们只需要将项目的源代码编译成Dll或者在.Net Core项目中直接引用相应的Nuget包 ...
- 死锁问题分析(个人认为重点讲到了gap间隙锁,解决了我一些不明报死锁的问题)
线上某服务时不时报出如下异常(大约一天二十多次):“Deadlock found when trying to get lock;”. Oh, My God! 是死锁问题.尽管报错不多,对性能目前看来 ...
- spring 启动脚本分析
参考:JVM 参数使用总结 参考:java -Xms -Xmx -XX:PermSize -XX:MaxPermSize 参考:JVM调优总结 -Xms -Xmx -Xmn -Xss 参考:JAVA ...
- 11/5/2018模拟 Problem C
题面 题解 我有特殊的哈希技巧 以到下一个相同字符的距离为值哈希, 如果不存在或在串外, 就是 \(|T| + 1\). 加入一个新字符 \(S_i\) 时, 同时修改它上一次出现时的值, 由 \(| ...
- 了解AutoCAD对象层次结构 —— 6 ——块表记录
块表记录是包裹实体对象的最后一层包装了,接下来让我们继续利用MgdDbg工具查看上一小节创建的块定义内的对象有哪些. 操作步骤如下:选择块表记录TestBlock,在右侧列表中找到“Entities ...
- eolinker——添加项目成员
https://help.eolinker.com/account/?target=/md/workspace/team 在工作空间的主页面,而不是接口的主页面这个一定要注意,邀请方式有两种,根据自己 ...
- Vue——显示微信用户名称中enjoin表情
后端做了处理转为了Unicode编码存入数据库,但是取出来没做处理,所以前端就做下简单的处理 转换代码: function decodeUnicode(str) { str = str.replace ...
- UOJ274 [清华集训2016] 温暖会指引我们前行 【LCT】【最大生成树】
题目分析: 差评,最大生成树裸题.hack数据还卡常. 代码: #include<bits/stdc++.h> using namespace std; ; struct LCT{ ],d ...
- selenium+python启动Firefox浏览器失败问题和点击登陆按钮无效问题
问题1:使用python+selenium编写脚本调用Firefox时报错:
- day4 linux安装python
linux 安装 python centos6 默认安装的是2.6,如果需要安装更高版本需要手动下载安装 下载源码包wget https://www.python.org/ftp/python/3.5 ...