码迷,mamicode.com
首页 > 其他好文 > 详细

HackerRank "Vertical Rooks"

时间:2016-02-11 06:45:36      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

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")

 

HackerRank "Vertical Rooks"

标签:

原文地址:http://www.cnblogs.com/tonix/p/5186290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!