import java.util.*;
public class Solution {
/**
* 进制转换
* @param M int整型 给定整数
* @param N int整型 转换到的进制
* @return string字符串
*/
public String solve (int M, int N) {
if (M == 0) {
return "0";
}
String s = "0123456789ABCDEF";
StringBuilder sb = new StringBuilder();
boolean flag = false;
if (M < 0) {
M = -M;
flag = true;
}
while (M != 0) {
sb.append(s.charAt(M % N));
M = M / N;
}
if (flag) {
sb.append("-");
}
return sb.reverse().toString();
}
}