为什么我的 Python 程序会发出运行时错误 - NZEC(非零退出代码)? [英] Why does my Python program issue a runtime error- NZEC( Non-zero exit code)?

查看:41
本文介绍了为什么我的 Python 程序会发出运行时错误 - NZEC(非零退出代码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 11 月挑战的 CodeChef 问题.我无意作弊.我的程序适用于提供的测试输入.但是服务器生成运行时 NZEC 错误.你能帮我找出我的错误吗?

This is a CodeChef problem for the November challenge. I donot intend to cheat. My program works well for the test input provided. But the server generates a runtime NZEC error. Can you help me identify my mistake?

T= raw_input()
for i in xrange(int(T)):
    G= raw_input()
    for j in xrange(int(G)):
        I, N, Q = raw_input().split()
        I= int(I)
        N= int(N)
        Q= int(Q)
        a= [I]*N
        print a
        count=0
        for k in xrange(N):
            if((N-k) % 2 != 0):
                if a[k]==1:
                    a[k]=2
                else: a[k]=1
        print a
        for k in xrange(N):
            if( a[k] == Q):
                count= count+1
        print count

非常感谢.

推荐答案

问题描述 表示 N 可以是 10**9.所以 a= [I]*N 可能需要几 GB 的内存.您的程序可能会因 MemoryError 异常而终止,该异常导致非零退出状态 (1).

The problem description says that N can be 10**9. So a= [I]*N might require several gigabytes of memory. Your program probably terminates with MemoryError exception that leads to non-zero exit status (1).

这篇关于为什么我的 Python 程序会发出运行时错误 - NZEC(非零退出代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆