Python 2.7 用python编写代码时codechef中出现nzec错误

Python 2.7 用python编写代码时codechef中出现nzec错误,python-2.7,runtime-error,Python 2.7,Runtime Error,当我在Codchef中编译它时,这段代码给出了运行时错误(NZEC) 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_cas

当我在Codchef中编译它时,这段代码给出了运行时错误(NZEC)

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;

若有任何异常抛出,则codechef中的代码将抛出NZEC错误。在CoeCHIFF -

上使用Python时,输入不象C、C++那样工作。 你可以用

import sys
test_cases = sys.stdin.read().split()
现在迭代测试用例。更多信息

对于输出也使用
sys.stdout.write()
,而不是
print