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 + 10;
const int seed = 131;
const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
int main(){
    int T, r, c, Case = 1;
    ll n, ans;
    scanf("%d", &T);
    while(T--){
        ans = 0;
        scanf("%d%d", &r, &c);
        for(int i = 1; i <= r; i++){
            for(int j = 1; j <= c; j++){
                scanf("%lld", &n);
                int dis = r - i + c - j;
                if(dis & 1) ans ^= n;
            }
        }
        if(ans) printf("Case %d: win\n", Case++);
        else printf("Case %d: lose\n", Case++);
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/KirinSB/p/9706787.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值