http://t.csdn.cn/4lpW8

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
     ll n,r;
     cin>>n>>r;
     if(n==0) {
         cout<<"0=0(base"<<r<<")"<<endl;
         return 0;
     }
     ll nn=n;
     vector<ll> ve;
     while(n) {
         ll mod=n%r;
         n/=r;
         if(mod<0) n++,mod-=r;
         ve.push_back(mod);
     }
     reverse(ve.begin(),ve.end());
     
     cout<<nn<<"=";
     for(auto x:ve) {
         if(x<10) cout<<x;
         else cout<<char('A'+x-9-1);
     }
     cout<<"(base"<<r<<")"<<endl;
     
     
     
     return 0;
 }