Codechef问题REDONE中的Runtime-NZEC错误

时间:2019-05-12 15:49:30

标签: python python-3.x pycharm

当我提交此文件时,它在Codechef上显示NZEC错误。我可以使用自己的输入在pycharm甚至在codechef编译器上运行它(如下所述) 但是codechef不接受这一点。请帮助我,我是Codechef的新手

这里t是测试用例。我不得不将测试用例放在输入数组中,因为我不知道如何在单行输入中输入整数和数组

import array
a=list(map(int,input().split()))
t=a[0]
a.pop(0)
for i in range(t):
    n=a[i]
    arr=array.array('i',[])
    for i in range(n):
        arr.append(i+1)
    while(n>1):
        x=arr[0]
        y=arr[n-1]
        arr.pop(0)
        arr.pop()
        z=x+y+(x*y)
        arr.append(z)
        n-=1
    print(arr[0])

在pycharm上使用: 输入: 3 1 2 4 输出: 1个 5 119

1 个答案:

答案 0 :(得分:0)

在读取输入时您犯了一个错误。 读取空格分隔的输入和python中的多行输入之间有区别,如下所示。

3 1 2 4

3
1
2
4

使用它来读取python中的输入:

for i in range(input()):
    n = input()

    ... use the value of n here
相关问题