BNUOJ 13105 nim博弈
ncredible Chess
This problem will be judged on LightOJ. Original ID: 1186
64-bit integer IO format: %lld      Java class name: Main
You are given an n x n chess board. Only pawn is used in the 'Incredible Chess' and they can move forward or backward. In each column there are two pawns, one white and one black. White pawns are placed in the lower part of the board and the black pawns are placed in the upper part of the board.
The game is played by two players. Initially a board configuration is given. One player uses white pieces while the other uses black. In each move, a player can move a pawn of his piece, which can go forward or backward any positive integer steps, but it cannot jump over any piece. White gives the first move.
The game ends when there is no move for a player and he will lose the game. Now you are given the initial configuration of the board. You have to write a program to determine who will be the winner.
Input
Input starts with an integer T (≤ 200), denoting the number of test cases.
Each case starts with an integer n (3 ≤ n ≤ 100) denoting the dimension of the board. The next line will contain n integers, W0, W1, ..., Wn-1 giving the position of the white pieces. The next line will also contain n integers, B0, B1, ... Bn-1 giving the position of the black pieces. Wimeans the row position of the white piece of ith column. And Bi means the row position of the black piece of ith column. You can assume that (0 ≤ Wi < Bi < n) for (0 ≤ i < n) and at least one move is remaining.
Output
For each case, print the case number and 'white wins' or 'black wins' depending on the result.
Sample Input
Sample Input | 
Output for Sample Input | 
| 
 2 6 1 3 2 2 0 1 5 5 5 3 1 2 7 1 3 2 2 0 4 0 3 4 4 3 1 5 6  | 
 Case 1: black wins Case 2: white wins  | 
Source
/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
#define A first
#define B second
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int t;
int a[];
int b[];
int n;
int ans;
int main()
{
scanf("%d",&t);
for(int i=; i<=t; i++)
{
scanf("%d",&n);
for(int j=; j<=n; j++)
scanf("%d",&a[j]);
for(int j=; j<=n; j++)
scanf("%d",&b[j]);
ans=;
for(int j=; j<=n; j++)
{
if(a[j]>b[j])
ans=ans^(a[j]-b[j]-);
else
ans=ans^(b[j]-a[j]-);
}
if(ans==)
printf("Case %d: black wins\n",i);
else
printf("Case %d: white wins\n",i);
}
return ;
}
BNUOJ 13105 nim博弈的更多相关文章
- HDU 2509 Nim博弈变形
		
1.HDU 2509 2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...
 - HDU 1907  Nim博弈变形
		
1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...
 - zoj3591 Nim(Nim博弈)
		
ZOJ 3591 Nim(Nim博弈) 题目意思是说有n堆石子,Alice只能从中选出连续的几堆来玩Nim博弈,现在问Alice想要获胜有多少种方法(即有多少种选择方式). 方法是这样的,由于Nim博 ...
 - hdu 1907 John&& hdu 2509 Be the Winner(基础nim博弈)
		
Problem Description Little John is playing very funny game with his younger brother. There is one bi ...
 - 关于NIM博弈结论的证明
		
关于NIM博弈结论的证明 NIM博弈:有k(k>=1)堆数量不一定的物品(石子或豆粒…)两人轮流取,每次只能从一堆中取若干数量(小于等于这堆物品的数量)的物品,判定胜负的条件就是,最后一次取得人 ...
 - HDU - 1850 Nim博弈
		
思路:可以对任意一堆牌进行操作,根据Nim博弈定理--所有堆的数量异或值为0就是P态,否则为N态,那么直接对某堆牌操作能让所有牌异或值为0即可,首先求得所有牌堆的异或值,然后枚举每一堆,用已经得到的异 ...
 - 博弈论中的Nim博弈
		
瞎扯 \(orzorz\) \(cdx\) 聚聚给我们讲了博弈论.我要没学上了,祝各位新年快乐.现在让我讲课我都不知道讲什么,我会的东西大家都会,太菜了太菜了. 马上就要回去上文化课了,今明还是收下尾 ...
 - HDU 2176:取(m堆)石子游戏(Nim博弈)
		
取(m堆)石子游戏 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
 - hdu 1730 Nim博弈
		
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1730 Nim博弈为:n堆石子,每个人可以在任意一堆中取任意数量的石子 n个数异或值为0就后手赢,否则先 ...
 
随机推荐
- Kanzi入门
			
1.安装Kanzi. 2.使用Kanzi studio创建工程. Kanzi创建的工程会包含以下目录结构: 其中, Tool_project文件夹中存放的是设计师设计的工程,包含kanzi UI的工程 ...
 - 视频播放器之————JW Player参数详解
			
JW Player参数详解 1,安装 下载后,你可以得到一个例子,当用文本或HTML编辑器打开的时候,你可以发现swf是用一段短小的 javascript嵌入到页面上的.这个Javascript是Ge ...
 - Android ViewPager实现选项卡切换
			
ViewPager实现选项卡切换,效果图如下: 步骤一:这里使用兼容低版本的v4包进行布局,这里eclipse没有输入提示,所以要手动输入,文件名称“activity_main.xml” <Re ...
 - Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置
			
原文:http://www.cnblogs.com/lixiaolun/archive/2013/12/07/3462780.html 1.下载源代码:http://www.igniterealtim ...
 - ReentRantLock使用
			
synchronized原语和ReentrantLock在一般情况下没有什么区别,但是在非常复杂的同步应用中,请考虑使用ReentrantLock,特别是遇到下面2种需求的时候. 1.某个线程在等待一 ...
 - 项目打包文件build.xml
			
Make命令其实就是一个项目管理工具,而Ant所实现功能与此类似.像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant却克服了这些工具的缺陷.最初Ant开发者在开发跨平台的应用 ...
 - 使用sublime时报编码错误
			
在执行Python脚本时报如下错误: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-78: ordin ...
 - linux性能测试命令-----top
			
Top命令显示了实际CPU使用情况,默认情况下,它显示了服务器上占用CPU的任务信息,并且每5秒钟刷新一次.它会显示CPU使用量.内存使用量.交换内存.缓存大小.缓冲区大小.流程PID.用户.命令等. ...
 - python 学习笔记-----编码问题
			
1.python 最早支持的是ASCII编码. 所以对于普通的字符串"ABC"为ASCII编码的形式.字母和数字之间的转换函数为ord('字母')和chr(‘数字’)函数. ord ...
 - varchar类型转换为numeric的值时有问题原因
			
numeric的值不应该用单引号括起来...........