#29490: 測資為什麼只有60%,到底問題在哪? 麻煩指正一下


notruth1492@gmail.com (fu yao shih)

學校 : 不指定學校
編號 : 99359
來源 : [163.27.169.254]
最後登入時間 :
2024-02-17 12:24:14
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [1.200.136.245] | 發表日期 : 2022-03-06 11:30

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%,到底問題在哪?

 
#29493: Re:測資為什麼只有60%,到底問題在哪? 麻煩指正一下


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [27.247.9.93] | 發表日期 : 2022-03-06 13:37

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%,到底問題在哪?

 

你有看題目嗎?你的程式連範例都過不了...
題目要求輸出邏輯運算,有多種可能,你只有輸出一種而已,當然會錯

 
ZeroJudge Forum