python求解
先转成10进制,再用10进制转成要的:
a,b = map(int,input().split())
number = input()
# 先变成10进制
number = int(number,a)
ans = ""
while number>0:
mid = int(number%b)
if mid>=10:
mid = mid-10+ord('a')
mid = chr(mid)
ans = str(mid)+ans
number = number/b
if number<1:
break
print(ans)
登录后发布评论
暂无评论,来抢沙发