#0: 10% AC (16ms, 3.3MB)
通過檢測
#1: 10% AC (16ms, 3.4MB)
通過檢測
#2: 10% AC (16ms, 3.4MB)
通過檢測
#3: 10% AC (16ms, 3.4MB)
通過檢測
#4: 10% AC (16ms, 3.4MB)
通過檢測
#5: 10% AC (18ms, 3.3MB)
通過檢測
#6: 10% AC (16ms, 3.3MB)
通過檢測
#7: 10% AC (16ms, 3.3MB)
通過檢測
#8: 10% WA (line:1)
您共輸出 0 行。
#9: 10% WA (line:1)
您共輸出 0 行。
while True:
try:
a1, b1, c1, a2, b2, c2 = map(int, input().split())
delta = a1*b2 - b1*a2
delta_x = c1*b2 - b1*c2
delta_y = a1*c2 - c1*a2
if delta == 0:
if delta_x == 0 and delta_y == y:
print('Too many')
else:
print('No answer')
else:
x = str(round(delta_x / delta, 2))
y = str(round(delta_y / delta, 2))
if '.' in x:
if len([i for i in x.split('.')][1]) == 1:
x = x + '0'
else:
x = x + '.00'
if '.' in y:
if len([i for i in y.split('.')][1]) == 1:
y = y +'0'
else:
y = y + '.00'
print(f'x={x}')
print(f'y={y}')
except:
break
先把縮排改好吧,你貼上來縮排都不見了,實在是不知道程式碼原本是長怎樣...
#0: 10% AC (16ms, 3.3MB)
通過檢測
#1: 10% AC (16ms, 3.4MB)
通過檢測
#2: 10% AC (16ms, 3.4MB)
通過檢測
#3: 10% AC (16ms, 3.4MB)
通過檢測
#4: 10% AC (16ms, 3.4MB)
通過檢測
#5: 10% AC (18ms, 3.3MB)
通過檢測
#6: 10% AC (16ms, 3.3MB)
通過檢測
#7: 10% AC (16ms, 3.3MB)
通過檢測
#8: 10% WA (line:1)
您共輸出 0 行。
#9: 10% WA (line:1)
您共輸出 0 行。
while True:
try:
a1, b1, c1, a2, b2, c2 = map(int, input().split())
delta = a1*b2 - b1*a2
delta_x = c1*b2 - b1*c2
delta_y = a1*c2 - c1*a2
if delta == 0:
if delta_x == 0 and delta_y == y:
print('Too many')
else:
print('No answer')
else:
x = str(round(delta_x / delta, 2))
y = str(round(delta_y / delta, 2))
if len([i for i in x.split('.')][1]) == 1:
x = x + '0'
else:
x = x + '.00'
if len([i for i in y.split('.')][1]) == 1:
y = y +'0'
else:
y = y + '.00'
print(f'x={x}')
print(f'y={y}')
except:
break
先把縮排改好吧,你貼上來縮排都不見了,實在是不知道程式碼原本是長怎樣...
while True:
try:
a1, b1, c1, a2, b2, c2 = map(int, input().split())
delta = a1*b2 - b1*a2
delta_x = c1*b2 - b1*c2
delta_y = a1*c2 - c1*a2
if delta == 0:
if delta_x == 0 and delta_y == y:
print('Too many')
else:
print('No answer')
else:
x = str(round(delta_x / delta, 2))
y = str(round(delta_y / delta, 2))
if len([i for i in x.split('.')][1]) == 1:
x = x + '0'
else:
x = x + '.00'
if len([i for i in y.split('.')][1]) == 1:
y = y +'0'
else:
y = y + '.00'
print(f'x={x}')
print(f'y={y}')
except:
break
先把縮排改好吧,你貼上來縮排都不見了,實在是不知道程式碼原本是長怎樣...
if delta_x == 0 and delta_y == y:
except:
delta_y == y改成delta_y == 0
不建議使用except:,可以改成except EOFError:,不然其他錯誤就會被吃掉。改掉就會出現錯誤訊息:
您的程式被監控系統中斷,可能是程式無法正常結束所導致。 Traceback (most recent call last): File "/9256210/code_9256210.py", line 8, in if delta_x == 0 and delta_y == y: NameError: name 'y' is not defined
if delta_x == 0 and delta_y == y:
except:
delta_y == y改成delta_y == 0
不建議使用except:,可以改成except EOFError:,不然其他錯誤就會被吃掉。改掉就會出現錯誤訊息:您的程式被監控系統中斷,可能是程式無法正常結束所導致。 Traceback (most recent call last): File "/9256210/code_9256210.py", line 8, in if delta_x == 0 and delta_y == y: NameError: name 'y' is not defined
謝謝,我要再精進錯誤處理的部分