当我提交此内容时,它在 Codechef 上显示 NZEC 错误。我可以使用我自己的输入在 pycharm 甚至 codechef 编译器上运行它(如下所述) 但 codechef 不接受这一点。请帮助我,我是 codechef 的新手
这里是测试用例。我必须将测试用例放在输入数组中,因为我不知道如何在单行输入中输入整数和数组
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
最佳答案
您在读取输入时犯了一个错误。 python 中读取空格分隔输入和多行输入之间存在差异,如下所示。
3 1 2 4
和
3
1
2
4
用它来读取 python 中的输入:
for i in range(input()):
n = input()
... use the value of n here
关于python - codechef 问题 REDONE 中的运行时 NZEC 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56100917/