Crazy Calendar (阶梯博弈变形)
2011 was a crazy year. Many people all over the world proposed on 11-11-11, married on 11-11-11, some even went through surgery only to have 11-11-11 as their child's birth date. How crazy people can be! Don't they see there is a "20" hidden? Then what to do? A very elegant solution came from ARR, a very famous and funny character - why do we need to follow Christian (or some calls it Gregorian) calendar? Why don't we start our own calendar on the day of marriage? And those who like to celebrate their marriage ceremony too frequent, why don't they declare only 1 day per year. In that fashion they can celebrate their anniversary every day. And may be one minute a year or a second or ... Uh.. getting complex. Let's back to the title. From now, we start to have a new calendar system, "Kisu Pari Na". And we hope to update this calendar on every national contest.
The purpose of this calendar is - we all will try our best to learn something new in every year. For this first year let's learn some combinatory. It reminds me of my first year in college. I faced this problem but could not solve this then. But see how easy it is:
Say you start from upper left cell and want to go to lower right cell. The only restriction is you can only move downward or rightward. How many ways are there? How to solve it? Not that difficult. You have to go two times Down and three times Right (whichever way you try) to reach the goal from the starting cell, right? So the answer is number of ways you can arrange two D (represents Down) and three R (represent Right). 2 same characters and 3 same characters, total 5 characters. So it is:
Or = D+RCR. Easy isn't it?
Ok enough with learning. Now back to problem, given a grid and at each cell there are some coins. Inky and Pinky are playing a game getting inspiration from the above problem. At each turn, a player chooses a non empty cell and then removes one or more coins from that cell and put them to the cell exactly right of it or exactly beneath it. A player can't divide the coins and put one part to right and others to down. Note that, for the cells at the right column the player can't move it to more right, and same for the bottom-most row. So a player can't move coins from the lower right cell. The game will finish when no moves are available and the player who moved last will win. Now inky being very modest asked Pinky to move first. Can you say if Pinky will win if both play perfectly?
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing two integers R C (1 ≤ R * C ≤ 50000), where R denotes the number of rows and C denotes the number of columns of the grid respectively. Each of the next R lines contains C space separated integers denoting the grid. These integers lie in the range [0, 109].
Output
For every test case, output case number followed by "win" if Pinky can win or "lose".
Sample Input
1
2 2
1 1
1 1
Sample Output
Case 1: lose
/*
* @Author: lyuc
* @Date: 2017-04-25 20:23:56
* @Last Modified by: lyuc
* @Last Modified time: 2017-04-25 20:41:17
*/
/*题意:给你一个n*m的矩阵,每个格子里都有一定数量的石头,两个人轮流移动石头,每次选择一个格子,移动至少一个石头,
* 但是只能移动到右边一个,或者下边一个格子,谁不能移动了就输了。
*
*初步思路:如果这个格子到右下角的步数是偶数的话,那么就不用考虑这个格子了,因为如果是偶数,那么先手移动几个,后手
* 就移动几个,这样就抵消了。所以只需要考虑奇数步数的格子,这就是一个简单的NIM博弈了
*//
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int t;
int n,m;
int num;
LL res;
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
printf("Case %d: ",ca);
res=;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
scanf("%d",&num);
if(((n+m)-(i+j))%)
res^=num;
}
}
printf(res?"win\n":"lose\n");
}
return ;
}
Crazy Calendar (阶梯博弈变形)的更多相关文章
- HDU 4315 阶梯博弈变形
n个棋子,其中第k个是红色的,每个棋子只能往上爬,而且不能越过.重叠其他棋子,谁将红色棋子移到顶部谁赢. 由于只能往上爬,所以很像阶梯博弈.这题有2个限制,棋子不能重叠,有红棋存在 首先不考虑红色棋, ...
- HDU 3389 阶梯博弈变形
n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输 选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法 ...
- LightOJ 1393 Crazy Calendar(博弈)题解
题意:r*c方格中,每个格子有一定石子,每次移动每格任意数量石子,只能向下或者向右动一格,不能移动为败 思路:显然是Nim,到右下曼哈顿距离为偶数的不用管,因为先手动一下后手动一下最后移到右下后还是先 ...
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- hdu4318阶梯博弈nim变形
阶梯博弈原理参考:http://www.cnblogs.com/jiangjing/p/3849284.html 这题计算每两个之间的间隔就行了,如果是奇数个就把第一个前面的看作一个,偶数个就是两个点 ...
- HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)
Climbing the Hill Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Su ...
- POJ1704 Georgia and Bob (阶梯博弈)
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Subm ...
- HDU 4315:Climbing the Hill(阶梯博弈)
http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:有n个人要往坐标为0的地方移动,他们分别有一个位置a[i],其中最靠近0的第k个人是king,移动的 ...
- hdu 3389 Game (阶梯博弈)
#include<stdio.h> int main() { int t,n,ans; int i,j,x; scanf("%d",&t); ;j<=t; ...
随机推荐
- [解读REST] 4.基于网络应用的架构风格
上篇文章介绍了一组自洽的术语来描述和解释软件架构:如何利用架构属性评估一个架构风格:以及对于基于网络的应用架构来说,那些架构属性是值得我们重点关注评估的.本篇在以上的基础上,列举一下一些常见的(RES ...
- 乐橙谷浅析JAVA程序员就业前景
不知道大家对Java就业前景了解多少.随着信息化的发展,IT培训受倒了越来越多人的追捧.在开发领域,JAVA培训成为了许多人的首选!JAVA应用广泛,JAVA培训就业前景良好!目前,虽然JAVA人才的 ...
- webpack2系列step1
第一篇:HTML 本文将一步一步的介绍webpack2的配置,从最基础的一直到与node结合. 操作都一样: midir step1 && cd step1 npm init -y n ...
- spring 面向切面(AOP)
AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术. AOP与OOP是面向不同领域的两种设计思想. ...
- FastDFS 分布式文件系统的安装与使用
跟踪服务器:192.168.152.129 (centos1) 存储服务器:192.168.152.130 (centos2) 环境:CentOS 6.6 用户:root 数据目录:/fastdfs ...
- Asp.net MVC4高级编程学习笔记-视图学习第三课Razor页面布局20171010
Razor页面布局 1) 在布局模板页中使用@RenderBody标记来渲染主要内容.比如很多web页面说头部和尾部相同,中间内容部分使用@RenderBody来显示不同的页面内容. 2) 在布局 ...
- Nginx 1.10.1 版本nginx.conf优化配置及详细注释
Nginx 1.10.1 的nginx.conf文件,是调优后的,可以拿来用,有一些设置无效,我备注上了,不知道是不是版本的问题,回头查一下再更正. #普通配置 #==性能配置 #运行用户 user ...
- 执行manage.py syncdb提示Unknown command: 'syncdb'
1. 实验环境 ubuntu14.4 + django1.9.7 2. 问题描述 在配置完数据库mysite/settings.py后,通常需要运行 python manage.py syncdb 为 ...
- Java视频扩展知识 线程池的了解
Java视频扩展知识 线程池的了解 1.简单介绍: Jdk1.5之后加入了java.util.concurrent包,这个包中主要介绍java中线程以及线程池的使用.为我们在开发中处理线程的 ...
- 如何结合场景利用block进行回调
我们在开发中常常会用到函数回调,你可以用通知来替代回调,但是大多数时候回调是比通知方便的,所以何乐而不为呢?如果你不知道回调使用的场景,我们来假设一下: 1.我现在玩手机 2.突然手机没有电了 3.我 ...