python
#
# 进制转换
# @param M int整型 给定整数
# @param N int整型 转换到的进制
# @return string字符串
#
class Solution:
def getStr(self, digit):
if digit < 10:
return str(digit)
else:
return chr(ord('A') + digit - 10)
def solve(self , M , N ):
# write code here
if M < 0:
return '-' + self.solve(-M, N)
res = ''
while M != 0:
digit = M % N
res += self.getStr(digit)
M = M // N
return res[::-1]