LightOJ 1393 Crazy Calendar(博弈)题解
题意:r*c方格中,每个格子有一定石子,每次移动每格任意数量石子,只能向下或者向右动一格,不能移动为败
思路:显然是Nim,到右下曼哈顿距离为偶数的不用管,因为先手动一下后手动一下最后移到右下后还是先手的回合;奇数移动一格必到偶数格,所以奇数的Nim一下。很简单的入门题。
代码:
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
typedef long long ll;
const int maxn = 5e4 + ;
const int seed = ;
const ll MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
using namespace std;
int main(){
int T, r, c, Case = ;
ll n, ans;
scanf("%d", &T);
while(T--){
ans = ;
scanf("%d%d", &r, &c);
for(int i = ; i <= r; i++){
for(int j = ; j <= c; j++){
scanf("%lld", &n);
int dis = r - i + c - j;
if(dis & ) ans ^= n;
}
}
if(ans) printf("Case %d: win\n", Case++);
else printf("Case %d: lose\n", Case++);
}
return ;
}
LightOJ 1393 Crazy Calendar(博弈)题解的更多相关文章
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- light oj 1393 - Crazy Calendar 博弈论
思路:当移到右下角时,就不能移动了.所以与右下角的奇偶性相同的位置,都不能直接到达,先手必败! 只需考虑与右下角奇偶不同的位置,可以看成NIM博弈.最后NIM和不为0的胜,否者败!! 代码如下: #i ...
- Crazy Calendar (阶梯博弈变形)
2011 was a crazy year. Many people all over the world proposed on 11-11-11, married on 11-11-11, som ...
- [LeetCode] 729. My Calendar I 731. My Calendar II 732. My Calendar III 题解
题目描述 MyCalendar主要实现一个功能就是插入指定起始结束时间的事件,对于重合的次数有要求. MyCalendar I要求任意两个事件不能有重叠的部分,如果插入这个事件会导致重合,则插入失败, ...
- Leading and Trailing LightOJ - 1282 题解
LightOJ - 1282 Leading and Trailing 题解 纵有疾风起 题目大意 题意:给你一个数n,让你求这个数的k次方的前三位和最后三位. \(2<=n<2^{31} ...
- 数学3(博弈+splya)
数学3(博弈+splya) 标签: 数学 hdu_5194 (打表找规律) 题意 有n和黑球和m个白球,现在一个个的取出这些球,如果是黑球则当前标记为1,白球为0,那么当取完这些球会得到一些序列.问你 ...
- HDU1848 Fibonacci again and again SG函数
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- LightOJ - 1247 Matrix Game (Nim博弈)题解
题意: 给一个矩阵,每一次一个玩家可以从任意一行中选任意数量的格子并从中拿石头(但最后总数要大于等于1),问你谁赢 思路: 一开始以为只能一行拿一个... 将每一行石子数相加就转化为经典的Nim博弈 ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
随机推荐
- 解决VMware虚拟机的CentOS无法上网
1)点击 VM->Settings Hardware选项卡下面 2)点击Network Adapter 设置如下图所示,首先我们在虚拟机中将网络配置设置成NAT 在服务中开启: VMware D ...
- (3.13)mysql基础深入——mysql日志分析工具之mysqlsla【待完善】
(3.13)mysql基础深入——mysql 日志分析工具之mysqlsla 关键字:Mysql日志分析工具.mysqlsla 常用工具 [1]mysqldumpslow:官方提供的慢查询日志分析工具 ...
- Git Gui 查看分支历史的时候中文显示乱码
如图所示 解决方案1 在Git Gui工具栏上选择-编辑-选项: 选择:Default File Contents Encoding, change为UTF-8 成功: 解决方案2 C:\Users ...
- vue.set的用法
Vue.set(this.food,'count',1) //就是给this.food里面添加一个count的属性,并且赋值为1
- [wx]自然数学规律
有趣的数学规律 椭圆 双曲线 抛物线都叫圆锥曲线 它们跟圆锥有着怎样的关系? 他们都是圆锥与平面在不同姿势下交配的产物. 参考 椭圆 抛物线 小结 e: 离线率 P: 任意一点 F: 焦点 准线: 一 ...
- Biorhythms(中国剩余定理)
http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h ...
- PAT Battle Over Cities [未作]
1013 Battle Over Cities (25)(25 分) It is vitally important to have all the cities connected by highw ...
- [LeetCode] 415. Add Strings_Easy tag: String
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2 ...
- [LeetCode] 197. Rising Temperature_Easy tag: SQL
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- FM/FFM原理
转自https://tech.meituan.com/deep-understanding-of-ffm-principles-and-practices.html 深入FFM原理与实践 del2z, ...