在代码中找不到运行时错误的原因

时间:2019-04-07 07:01:06

标签: runtime-error python-3.6

我正在解决Google Codejam 2019资格回合的密码难题。我能够在我的机器上成功运行代码,但是在上载解决方案时,它返回运行时错误。 请帮助我找到运行时错误的原因。

代码

def gcd(a,b):
    for i in range(min(a,b),0,-1):
        if(a % i == 0 and b % i == 0):
            return i



if __name__=='__main__':
    alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    T = int(input())
    answers = ["" for i in range(T)]
    for i in range(0,T):
        N,L = [int(s) for s in input().split(" ")]  
        divisors = []
        values = [int(s) for s in input().split(" ")]
        div = gcd(values[0],values[1])
        divisors.append(int(values[0]/div))
        divisors.append(div)
        for j in values[1:len(values)]:
            div = int(j/div)
            divisors.append(div)
        primes = list(set(divisors))
        primes.sort()
        for j in range(0,len(divisors)):
            answers[i] += alphabets[primes.index(divisors[j])]
    for i in range(0,T):
        print("Case #{}: {}".format(i+1,answers[i]))

0 个答案:

没有答案