• HDU 1907


    传送门

    规则类似与NIM博弈,但是取到最后一颗石子的人输

    必败态有两种

    异或和不为0且(石子数多余1的堆)数目为0

    异或和为0且(石子数多余1的堆)数目大于1

     1 #include <queue>
     2 #include <vector>
     3 #include <cstdio>
     4 #include <cstring>
     5 #include <iostream>
     6 #include <algorithm>
     7 #define INF 0x3f3f3f3f
     8 #define MOD 1000000007
     9 using namespace std;
    10 typedef long long LL;
    11 
    12 
    13 
    14 int main(int argc, const char * argv[]) {
    15     int T;
    16     scanf("%d", &T);
    17     while (T--) {
    18         int val;
    19         int n;scanf("%d", &n);
    20         int tmp = 0, flag = 0;
    21         for (int i = 1; i <= n; i++) {
    22             scanf("%d", &val);
    23             tmp ^= val;
    24             if (val > 1) flag ++;
    25         }
    26         if ((tmp != 0 && flag == 0) || (tmp == 0 && flag > 1)) {
    27             puts("Brother");
    28         } else {
    29             puts("John");
    30         }
    31     }
    32     return 0;
    33 }
  • 相关阅读:
    字典
    字符串常用的方法
    切片,集合、文件处理
    蓝桥杯练习 Day6 题解
    spoj-ORDERS
    spoj-SUBSUMS
    spoj
    spoj --- ABCDEF
    C. Andryusha and Colored Balloons
    B. The Meeting Place Cannot Be Changed
  • 原文地址:https://www.cnblogs.com/xFANx/p/7280119.html
Copyright © 2020-2023  润新知