HDU 3032.Nim or not Nim?【SG函数打表找规律】【4月11】
来源:互联网 发布:淘宝退货会影响权重吗 编辑:程序博客网 时间:2024/06/05 20:49
Nim or not Nim?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1436 Accepted Submission(s): 706
Problem Description
Nim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap.
Nim is usually played as a misere game, in which the player to take the last object loses. Nim can also be played as a normal play game, which means that the person who makes the last move (i.e., who takes the last object) wins. This is called normal play because most games follow this convention, even though Nim usually does not.
Alice and Bob is tired of playing Nim under the standard rule, so they make a difference by also allowing the player to separate one of the heaps into two smaller ones. That is, each turn the player may either remove any number of objects from a heap or separate a heap into two smaller ones, and the one who takes the last object wins.
Nim is usually played as a misere game, in which the player to take the last object loses. Nim can also be played as a normal play game, which means that the person who makes the last move (i.e., who takes the last object) wins. This is called normal play because most games follow this convention, even though Nim usually does not.
Alice and Bob is tired of playing Nim under the standard rule, so they make a difference by also allowing the player to separate one of the heaps into two smaller ones. That is, each turn the player may either remove any number of objects from a heap or separate a heap into two smaller ones, and the one who takes the last object wins.
Input
Input contains multiple test cases. The first line is an integer 1 ≤ T ≤ 100, the number of test cases. Each case begins with an integer N, indicating the number of the heaps, the next line contains N integers s[0], s[1], ...., s[N-1], representing heaps with s[0], s[1], ..., s[N-1] objects respectively.(1 ≤ N ≤ 10^6, 1 ≤ S[i] ≤ 2^31 - 1)
Output
For each test case, output a line which contains either "Alice" or "Bob", which is the winner of this game. Alice will play first. You may asume they never make mistakes.
Sample Input
232 2 323 3
Sample Output
AliceBob
sg[4*k] = 4*k - 1;
sg[4*k +1] = 4*k + 1;
sg[4*k + 2] = 4*k + 2;
sg[4*k + 3] = 4*k - 1;
#include<iostream>#include<cstdio>using namespace std;int T, N, x, ans;int main(){ scanf("%d", &T); while(T--) { ans = 0; scanf("%d", &N); while(N--) { scanf("%d", &x); if(x%4 == 0) ans ^= (x-1); else if(x%4 == 3) ans ^= (x+1); else ans ^= x; } if(ans == 0) cout <<"Bob"<< endl; else cout <<"Alice"<< endl; } return 0;}
0 0
- HDU 3032.Nim or not Nim?【SG函数打表找规律】【4月11】
- hdu 3032 Nim or not Nim? (sg函数规律)
- hdu 3032 Nim or not Nim? (SG打表找规律)
- HDU 3032 Nim or not Nim? SG打表找规律
- HDU 3032 Nim or not Nim(SG函数打表找规律)
- hdu 3032 Nim or not Nim SG函数入门+打表找规律
- SG函数找规律练习-HDU3032- Nim or not Nim?
- hdu3032 Nim or not Nim? SG打表找规律
- HDU 3032 Nim or not Nim?(博弈 SG打表找规律)
- HDU 3032 Nim or not Nim? (sg函数)
- HDU 3032 Nim or not Nim? (sg函数求解)
- HDU 3032 Nim or not Nim?(sg函数博弈)
- HDU 3032-Nim or not Nim?(sg函数打表)
- HDU 3032 Nim or not Nim? (SG函数应用)
- (HDU 3032) Nim or not Nim(SG函数、博弈)
- hdu 3032 Nim or not Nim? (Multi-SG函数)
- HDU 2311-Nim or not Nim?(Nim博弈-打sg表找规律)
- hdu 3032 Nim or not Nim? 博弈(SG定理+找规律)
- android应用前后台切换的监听
- uva 10137 the trip
- Android 属性动画(Property Animation) 完全解析 (上)
- 前端构建:Less入了个门
- Unity LayerMask用法
- HDU 3032.Nim or not Nim?【SG函数打表找规律】【4月11】
- 简单springmvc搭建流程
- centos6.5安装配置cobbler
- Android 属性动画(Property Animation) 完全解析 (下)
- 关于位操作学习的一些记录
- 字符串操作函数的实现方法(代码)
- Navicat for Oracle 安装使用
- 最大乘积
- 多线程系列:TheadLocal