2015-11-19 87 views
2

我正在解決codechef上的問題,併成功測試了我的python代碼。由於某種原因,它說Runtime error NZEC代表「非零錯誤代碼」。Python代碼拋出運行時錯誤NZEC?

我的代碼:

N, M = input().split(" ") 
N = int(N) 
M = int(M) 
if (N % 5 == 0 and not N > M): 
    print (M - N - 0.50) 
else: 
    print (M) 

鏈接的問題: https://www.codechef.com/problems/HS08TEST

+0

無關,但你可能不希望做'M = INT(M)' – njzk2

+0

(也,你的結果是錯誤的) – njzk2

+0

Python版本是這樣的運行呢?如果它是2.x,則需要'raw_input'而不是'input'。 – interjay

回答

0

你的代碼是正確的幾乎只是需要一個行改變。

N, M = input().split(" ") 
N = int(N) 
# The line below has been changed because M when given at stdin is a 
# float value and during split it is converted to string. But a string 
# with decimal can't be converted directly to int, so, it needs to be 
# converted to float 
M = float(M) 
if (N % 5 == 0 and not N > M): 
    print (M - N - 0.50) 
else: 
    print (M) 
+0

感謝您提供寶貴的建議,但即使此代碼無法正常工作。我主要關心的是由所有python程序員提交的codechef問題的解決方案顯示相同的錯誤,因此沒有提交python提交。 codechef不支持的語言是否存在問題? –