首页 > 解决方案 > 在 codejam 2019 中提交代码时出现运行时错误

问题描述

因此,我尝试了 Codejam 2019 中的一些练习题。我针对以下问题的代码在本地 IDE 中完美运行,但在提交时出现运行时错误。你能帮我解决这个问题吗?

问题: 问题

我的代码:

def isprime(num):  
if num > 1 and num%2!=0:
   for i in range(2,num):
       if (num % i) == 0:
           return 0
   else:
       return 1

t=int(input())
tc=0
while t:
    t-=1
    tc+=1
    x=list(map(int, input().split()))
    n=x[0]
    m=x[1]
    l=list(map(int, input().split()))
    d={}
    path=""
    arr=[]
    for i in range(2,n):
        f=isprime(I)
        if f and l[0]%i==0:
            arr.append(i)
            arr.append(l[0]//i)
            break

    for i in range(1,len(l)):
        arr.append(l[i]//arr[len(arr)-1])
    x="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    j=0
    s=set(arr)
    s=sorted(s)
    for i in s:
        d[i]=x[j]
        j+=1


    for i in arr:
        path+=d[I]              
    print("Case #"+str(tc)+":",path)

输入:

2
103 31
217 1891 4819 2291 2987 3811 1739 2491 4717 445 65 1079 8383 5353 901 187 649 1003 697 3239 7663 291 123 779 1007 3551 1943 2117 1679 989 3053
10000 25
3292937 175597 18779 50429 375469 1651121 2102 3722 2376497 611683 489059 2328901 3150061 829981 421301 76409 38477 291931 730241 959821 1664197 3057407 4267589 4729181 5335543

预期输出:

Case #1: CJQUIZKNOWBEVYOFDPFLUXALGORITHMS
Case #2: SUBDERMATOGLYPHICFJKNQVWXZ

我的输出:

Case #1: CJQUIZKNOWBEVYOFDPFLUXALGORITHMS
Case #2: SUBDERMATOGLYPHICFJKNQVWXZ

我得到的错误

标签: pythonpython-3.xruntime-error

解决方案


推荐阅读