python - 在 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
解决方案
推荐阅读
- gnuplot - Gnuplot 多个带间距的 yerrorbars
- amazon-web-services - 在报告 AWS Backup Powershell 中添加 EC2 的名称
- elasticsearch - ElasticSearch - 如何在聚合中“折叠”文档
- powershell - Powershell脚本将文件从一个文件夹移动到同一文档库中的另一个文件夹
- python - Assigning a datetime object as the url parameter
- android-studio - Flutter Web App 错误:CHROME_EXECUTABLE="..." 不可执行
- sqlite - 内存数据库的内部架构
- html - 在其他元素之上的粘性元素而不离开容器
- android - react native rn-fetch-blob 无法读取 android 10 的存储
- c# - 在经典的 asp.net 表单应用程序中使用 websockets