while True:
try:
a,b,c=map(int,input().split())
if ((a==0 and b==0) or (a!=0 and b==0) or (a==0 and b!=0))and c==0:
print('AND')
elif (a!=0 and b!=0))and c==1:
print('AND')
elif (a==0 and b==0) and c==0:
print('OR')
elif ((a==0 and b!=0) or (a!=0 and b==0) or (a!=0 and b!=0))and c==1:
print('OR')
elif ((a==0 and b==0) or(a!=0 and b!=0)) and c==0:
print('XOR')
elif ((a==0 and b!=0) or(a!=0 and b==0)) and c==1:
print('XOR')
else:
print('IMPOSSIBLE')
except EOFError:break
為什麼只有60%,到底問題在哪?
while True:
try:
a,b,c=map(int,input().split())
if ((a==0 and b==0) or (a!=0 and b==0) or (a==0 and b!=0))and c==0:
print('AND')
elif (a!=0 and b!=0))and c==1:
print('AND')
elif (a==0 and b==0) and c==0:
print('OR')
elif ((a==0 and b!=0) or (a!=0 and b==0) or (a!=0 and b!=0))and c==1:
print('OR')
elif ((a==0 and b==0) or(a!=0 and b!=0)) and c==0:
print('XOR')
elif ((a==0 and b!=0) or(a!=0 and b==0)) and c==1:
print('XOR')
else:
print('IMPOSSIBLE')
except EOFError:break
為什麼只有60%,到底問題在哪?
你有看題目嗎?你的程式連範例都過不了...
題目要求輸出邏輯運算,有多種可能,你只有輸出一種而已,當然會錯