除和取余

class Solution {
public:
    string solve(int M, int N) {
        if(M == 0) return "0";
        bool neg = false;
        if(M<0){
            neg = true;
            M *= -1;
        }
        string has = "0123456789ABCDEF";
        string res = "";
        while(M){
            res = has[M%N]+res;
            M /= N;
        }
        if(neg)
            return "-"+res;
        else
            return res;
    }
};