为何一直提示Rumtime error,我用python3写的

much = int(input(''))
number = input('')
numsz = [int(x) for x in number.split(' ')]
sum = 0
numsz2=numsz[:]
for i in range(much):
for x in range(1, much):
if (x+i) < much:
if numsz[i] != numsz[x+i]:
jj = numsz[i]+numsz[x+i]
numsz2.remove(numsz[i])
numsz2.remove(numsz[x + i])
if jj in numsz2:
sum += 1
numsz2.remove(jj)
numsz2.append(numsz[i])
numsz2.append(numsz[x+i])
print (sum)

2 条评论

  • @ 2022-08-02 12:20:14
    k=input()
    m=input().split(" ")
    num=0
    tested=[]
    for i in m:
        for j in m:
            if str(int(i)+int(j)) in m and i!=j and not [i,j] in tested and not [j,i] in tested:
                num+=1
                tested.append([i,j])
    print(num)
    

    我这个也报Runtime Error

  • @ 2017-09-16 13:09:12

    为何还是错的·······

    much = int(input(''))
    number = input('')
    numsz = [int(x) for x in number.split(' ')]
    sum = 0
    numsz2=numsz[:]
    for i in range(much):
    for x in range(1, much):
    if (x+i) < much:
    if numsz[i] != numsz[x+i]:
    jj = numsz[i]+numsz[x+i]
    if jj in numsz2:
    if (numsz[i] != jj):
    if (numsz[x+i] != jj):
    sum += 1
    numsz2.remove(jj)
    print (sum)

  • 1

信息

ID
1911
难度
6
分类
(无)
标签
递交数
17041
已通过
4511
通过率
26%
被复制
27
上传者