LightOJ - 1247 Matrix Game (Nim博弈)题解
题意:
给一个矩阵,每一次一个玩家可以从任意一行中选任意数量的格子并从中拿石头(但最后总数要大于等于1),问你谁赢
思路:
一开始以为只能一行拿一个...
将每一行石子数相加就转化为经典的Nim博弈
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
const int N = 100000+5;
const int INF = 0x3f3f3f3f;
using namespace std;
int main() {
int T,m,n,a,Case = 1;
scanf("%d",&T);
while(T--){
scanf("%d%d",&m,&n);
int ans = 0;
for(int i = 0;i < m;i++){
int sum = 0;
for(int i = 0;i < n;i++){
scanf("%d",&a);
sum += a;
}
ans ^= sum;
}
if(ans == 0) printf("Case %d: Bob\n",Case++);
else printf("Case %d: Alice\n",Case++);
}
return 0;
}
LightOJ - 1247 Matrix Game (Nim博弈)题解的更多相关文章
- LightOJ 1186 Icreable Chess(Nim博弈)
You are given an n x n chess board. Only pawn is used in the 'Incredible Chess' and they can move fo ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- LightOJ 1253 Misere NIM(反NIM博弈)
Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, eac ...
- nim博弈 LightOJ - 1253
主要是写一下nim博弈的理解,这个题有点奇怪,不知道为什么判断奇偶性,如果有大佬知道还请讲解一下. //nim博弈 //a[0]~a[i] 异或结果为k 若k=0 则为平衡态 否则为非平衡态 //平衡 ...
- codeforces 812E Sagheer and Apple Tree(思维、nim博弈)
codeforces 812E Sagheer and Apple Tree 题意 一棵带点权有根树,保证所有叶子节点到根的距离同奇偶. 每次可以选择一个点,把它的点权删除x,它的某个儿子的点权增加x ...
- POJ2234:Matches Game(Nim博弈)
Matches Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12325 Accepted: 7184 题目链 ...
- hdu2509Be the Winner(反nim博弈)
Be the Winner Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu1907John(反nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- hdu1730Northcott Game(nim博弈)
Northcott Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
随机推荐
- A Bug's Life-----poj2492(关系并查集)
题目链接:http://poj.org/problem?id=2492 题意是问是否存在同性恋, 就是a喜欢b,b喜欢c,a又喜欢c,所以就有同性恋了: #include<stdio.h> ...
- 常用社交网络(微博等)动态新闻(feed、新鲜事)系统浅析(转)
add by zhj:同时也看看国外牛逼公司是怎么做的吧 Stream-Framework Python实现的feed Twitter 2013 Redis based, database fa ...
- Reporting Service Url传递参数应用
与sharepoint集成的报表传递参数示例: http://reportserver/reportcenter/_layouts/ReportServer/RSViewerPage.aspx?rv: ...
- /etc/redhat-release 查看centos 版本
查看centos 版本 [root@localhost ~]# cat /etc/redhat-release CentOS release 6.4 (Final)
- 002-nginx-在 nginx 反向代理中使用域名,配置动态域名解析
一.概述 代理(proxy),即中间人,它代替客户端发送请求给服务器,收到响应后再转给客户端.通常意义上的代理是从用户的角度讲的,用户通过某个代理可以访问多个网站,这个代理是靠近用户的,比如某些公司可 ...
- [py]彻底细究web框架的wsgi+逻辑处理模块
wsgi逻辑结构初探 参考: 这里图很精彩,wsgi写的不错 web框架 = wsgi+逻辑处理app 接收请求,返回对应的内容 python wsgiref实现了wsgi规范. from wsgir ...
- [py][mx]django自带后台系统使用
django的manytomany字段和后台搜索过滤功能 后台开发一般要求 后台要求能快速搭建, 主要精力放在前端用户系统开发上. 权限管理 少量样式 快速开发 django自带的后台手动注册模型 创 ...
- PAT 1074 Reversing Linked List[链表][一般]
1074 Reversing Linked List (25)(25 分) Given a constant K and a singly linked list L, you are suppose ...
- 重读《Java编程思想》
相关最新代码已上传至我的GitHub了(https://github.com/WenyangSun/ThinkingInJava),后续例子没有在博客上更新. 1.在类的内部,变量定义的先后顺序决定了 ...
- ComBSTR的使用
用 CComBSTR 进行编程 Visual Studio .NET 2003 3(共 3)对本文的评价是有帮助 - 评价此主题 ATL 类 CComBSTR 提供对 BSTR 数据类型的包装 ...