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 ...
随机推荐
- (C/C++)区别:数组与指针,指针与引用
1.数组跟指针的区别 数组要么在静态存储区被创建(如全局数组),要么在栈上被创建.数组名对应着(而不是指向)一块内存,其地址与容量在生命期内保持不变,只有数组的内容可以改变. 指针可以随时指向任意类型 ...
- PhpStorm 配置链接远程虚拟机
安装好了 PhpStorm 之后,打开项目文件夹,接着点击工具栏 Tools: 2.接着点击 tools>Deployment: 3.点击Configuration 开始配置 4.填好箭头 ...
- placeholder解决兼容各种IE浏览器的方法
<input id="search" type="text" class="box" class="inputText&qu ...
- solr配置ik中文分词(二)
上一篇文章主要介绍了solr的安装与配置,这篇文章主要记录如何使用ik分词器对中文进行分词. 步骤: 1.下载ik分词jar包:ik-analyzer-solr5-5.x.jar. 2.将下载的jar ...
- 一、hadoop部署
一.Java环境 yum 安装方式安装 1.搜索JDK安装包 yum search java|grep jdk 2.安装 yum install java-1.8.0-openjdk-src.x86_ ...
- 三、安装MyCat-Web
一.下载和解压MyCat-web http://dl.mycat.io/mycat-web-1.0/ wget http://dl.mycat.io/mycat-web-1.0/Mycat-web-1 ...
- 1.ansible基本参数介绍
想使用ansible 先--help学习下基本的options吧小兄弟1: -m 指定模块名称只有一个模块command 可以省略:-M 指出模块路径来加载2: -a 指定模块参数就是模块的内容你知道 ...
- codeforces545C
Woodcutters CodeForces - 545C Little Susie listens to fairy tales before bed every day. Today's fair ...
- poj2112(网络流-最大流+二分)
题意:给你k个挤奶器,c头牛,每个挤奶器能放m头牛,问你奶牛需要走的最大距离最小是多少: 解题思路:因为最大距离最小,也就是求最小的距离满足所有牛都能到,所以我们先用floyd跑最短路,把所有点之间的 ...
- luogu P1077 摆花
这道题看似好难,但是其实很简单 先把题目中所让你设的变量都设好,该输入的都输入 你会发现这道题好像成功了一半,为什么呢??? 因为设完后你会发现你不需要再添加任何变量,已经足够了. 可能最难的地方,就 ...