问题
This code is giving Runtime error (NZEC) when I compile it in Codchef.
test_cases = int(raw_input())
result = 0
def output(x):
if(x/2 >= 2):
global result;
result += x/2 - 1;
output(x-2);
else:
print result;
result = 0;
while(test_cases > 0):
base = int(raw_input());
output(base);
test_cases = test_cases - 1;
回答1:
NZEC error would be thrown by your code in codechef if there is any exception thrown. Input does not work like c, c++ while using python on codechef -
you can use
import sys
test_cases = sys.stdin.read().split()
Now iterate over test_cases. More info here
also use sys.stdout.write()
for outputs rather than print
来源:https://stackoverflow.com/questions/37499747/nzec-error-in-codechef-while-writing-code-in-python