nzec error in codechef while writing code in python

我只是一个虾纸丫 提交于 2020-01-30 13:13:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!