zoukankan      html  css  js  c++  java
  • HackerRank "Vertical Rooks"

    Please note: VROOK cannot go back-ward - that leads to a simple variation to Game of Nim: just XOR.

    t = int(input())
    for _ in range(t):
        n = int(input())
        # Get input
        p1 = []
        for _ in range(n): p1.append(int(input()))
        p2 = []
        for _ in range(n): p2.append(int(input()))
        # Game of Nim
        nim = 0
        for i in range(n):
            nim ^= abs(p2[i]- p1[i]) - 1
        print ("player-2" if nim != 0 else "player-1")
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/tonix/p/5186290.html
Copyright © 2011-2022 走看看