求助python 0pts

P1015 [NOIP1999 普及组] 回文数

Linune_Gump @ 2023-03-12 11:14:51

样例和第一个点本地都是对的,评测四个RE 0分 是不是python上交的时候要注意什么/lb

def tran(x, n):  # 把n进制数变为10进制数
    ans = 0
    for i in x:
        if "A" <= i <= 'Z':
            t = ord(i)-55
        else:
            t = int(i)
        ans = ans * n + t
    return ans

def trans_re(x):
    ans = ''
    while x != 0:
        r = x % n
        if r >= 10:
            r = chr(r + 55)
        else:
            r = str(r)
        ans = r + ans
        x //= n
    return ans

n = int(input())
x = input()
if len(x) >= 1:
    cnt = 0
    while cnt < 30:
        a = tran(x,n); b = tran(x[::-1],n)
        x = trans_re(a + b)
        if x == x[::-1]:
            print("STEP=", cnt + 1, sep = '')
            break
        cnt+=1
    else:
        print("Impossible!")

|