URI 在线判断 - 1026 - 携带或不携带 - 错误答案 (100%)



我试图在URL在线判断中解决这个问题:https://www.urionlinejudge.com.br/judge/en/problems/view/1026

使用Python,我的答案是:

v1, v2 = input().split()
v1, v2 = int(v1), int(v2)
res = v1 ^ v2
print(res)

结果我得到:"错误的答案(100%)"。我做错了什么?

正如@Ryan回答的那样,我必须阅读多行输入,因此,代码的开头是:

import sys
for line in sys.stdin:
    v1, v2 = [int(i) for i in line.split()]
    # The rest of the code here.

感谢您@Ryan的帮助!

while True:
try:
    list1 = input().split()
    X, Y = list1
    print(int(X) ^ int(Y))
except:
    break 

相关内容

最新更新