herofly


私信TA

用户名:pyhero

访问量:13850

签 名:

等  级
排  名 31
经  验 13753
参赛次数 17
文章发表 321
年  龄 0
在职情况 待业
学  校
专  业

  自我简介:

def n_to_ten(n,m):
    j = 0
    sum =0
    for i in str(m)[::-1]:
        sum += int(i)*n**j
        j += 1
    return sum
 
def ten_to_n(n,m):
    st=''
    while m!=0:
        st += str(m%n)
        m = m//n
    return st[::-1]
     
n = int(input())
m = int(input())
 
step = 0
while step <=30:
    step += 1
    if step == 31:
        print("Impossible!")
        break
    num = str(m)
    mun = num[::-1]
    ten_sum = n_to_ten(n,m)+n_to_ten(n,int(mun))
    n_sum = ten_to_n(n,ten_sum)
    st = str(n_sum)
    #print(st)
    if st==st[::-1]:
        print(f"STEP={step}")
        break
    else:
        m = n_sum


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区