LightOj 1186 Incredible Chess nim游戏
2015-09-09 14:24
162 查看
不知道这题放出来算不算凑数Orz;
题目大意就是 棋盘上每一纵列有黑白两个棋子, 黑色一定在白色上方,两个人一人各执一色, 白色先走,每次操作可以把自己的颜色向上或者向下移动任意格, 但是不能超出范围也不能越过另一色的棋, 无法操作的一方败。
移到比较经典的nim游戏题。。每一纵列黑白棋之间的空格数作为这一堆的石子数然后全部异或就行。。结果为0就先手败否者先手胜。
详细证明请移步:http://blog.csdn.net/tsaid/article/details/7010091。
代码就特别简单了、、:
题目大意就是 棋盘上每一纵列有黑白两个棋子, 黑色一定在白色上方,两个人一人各执一色, 白色先走,每次操作可以把自己的颜色向上或者向下移动任意格, 但是不能超出范围也不能越过另一色的棋, 无法操作的一方败。
移到比较经典的nim游戏题。。每一纵列黑白棋之间的空格数作为这一堆的石子数然后全部异或就行。。结果为0就先手败否者先手胜。
详细证明请移步:http://blog.csdn.net/tsaid/article/details/7010091。
代码就特别简单了、、:
#include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <string> #include <cctype> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <sstream> #include <iostream> #include <algorithm> using namespace std; #define ls id<<1,l,mid #define rs id<<1|1,mid+1,r #define OFF(x) memset(x,-1,sizeof x) #define CLR(x) memset(x,0,sizeof x) #define MEM(x) memset(x,0x3f,sizeof x) typedef long long ll ; typedef pair<int,int> pii ; const int maxn = 1e3+50 ; const int inf = 0x3f3f3f3f ; const int MOD = 1e9+7 ; int T,n,a[maxn]; char s[2][10] = {"black","white"}; int main () { #ifdef LOCAL freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin); // freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout); #endif int cas = 1; scanf("%d",&T); while (T--) { int cnt1 = 0, cnt2 = 0; printf("Case %d: ",cas++); scanf("%d",&n); for (int i = 0; i < n; i++) scanf("%d",a+i); int x; int p = 0; for (int i = 0; i < n; i++) { scanf("%d",&x); x -= a[i] + 1 ; if (x > 0) p ^= x ; } printf("%s wins\n",s[p != 0]); } return 0; }
相关文章推荐
- UICollectionView详解二
- fix an error while building native gdb via ct-ng
- Java synchronized详解 二
- Python对象及内存管理
- C++中智能指针的设计和使用
- [iOS开发]C语言-04-程序循环结构(while{})视频解说
- Ubuntu Server搭建svn服务以及迁移方法
- ASIHTTPRequest配置及常见问题
- hdu 2014 青年歌手大奖赛_评委会打分
- Advanced R之数据结构
- 实现流式布局
- webbrowser和IE
- Java synchronized详解 一
- Spark编译与部署(上)--基础环境搭建
- 计蒜客 第6题:泥塑课
- 计蒜客 第7题:奇怪的国家
- java创建多线程的三种方式
- POJ编译错误
- 3dmax2016新增加的panorama explorer的使用
- Centos默认的python2.6.6升级到python2.7.10全过程(包含setuptools/pip/django/yum设置)