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 人评分
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:1305 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:701 |
【偶数求和】 (C++代码)浏览:785 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:690 |
买不到的数目 (C++代码)浏览:909 |
淘淘的名单 (C语言代码)答案错误???浏览:624 |
计算质因子 (C++代码)浏览:1824 |
A+B for Input-Output Practice (V) (C语言代码)浏览:640 |
C二级辅导-阶乘数列 (C语言代码)浏览:736 |
WU-陶陶摘苹果2 (C++代码)浏览:1018 |