zoukankan      html  css  js  c++  java
  • HDU_1703 Northcott Game(博弈论)

      最近搞了一下博弈论,处于初级入门阶段,找了几个题做做,正巧碰上这题。这题是Nim博弈的一个变形,将两坐标的距离看作一堆石子中的石子数,n就是石子堆数,所以根据Nim博弈的结论:a1 ^ a2 ^ a3……^an == 0 ,则必胜。所以这题的答案就出来了。

    My Code:

    #include <iostream>
    #include <cstdio>

    using namespace std;

    int main(){
        //freopen("data.in", "r", stdin);
        int a, b, ans, tmp;
        int n, m;
        while(scanf("%d%d", &n, &m) != EOF){
            ans = 0;
            while(n--){
                scanf("%d%d", &a, &b);
                tmp = (a - b) > 0 ? (a - b - 1) : (b - a - 1);
                ans ^= tmp;
            }
            if(ans){
                puts("I WIN!");
            }else{
                puts("BAD LUCK!");
            }
        }
        return 0;
    }



  • 相关阅读:
    CodeForces
    CodeForces
    FZU
    FZU
    UESTC
    测试用例概述
    软件测试流程
    软件测试(二)软件测试过程
    软件测试(一)软件的生命周期(SDLC,Systems Development Life Cycle,SDLC)
    系统测试的策略
  • 原文地址:https://www.cnblogs.com/vongang/p/2185565.html
Copyright © 2011-2022 走看看