a, b, c = map(int, input().split())if a>0: a = 1if b>0: b = 1print("AND\n"*(a&b==c)+"OR\n"*(a|b==c)+"XOR\n"*(a^b==c), end='')if a&b==a|b==a^b!=c: print("IMPOSSIBLE")
前面三行可以改成 n = [int(_) % 2 for _ in input().split(' ') if _]
這樣就可以變成三行解了
a, b, c = map(int, input().split())if a>0: a = 1if b>0: b = 1print("AND\n"*(a&b==c)+"OR\n"*(a|b==c)+"XOR\n"*(a^b==c), end='')if a&b==a|b==a^b!=c: print("IMPOSSIBLE")前面三行可以改成 n = [int(_) % 2 for _ in input().split(' ') if _]
這樣就可以變成三行解了
改這樣會更有意義吧
a,b,c = map(bool, map(int, input().split()))