#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <vector> using namespace std; char intToChar(int n){ if(n < 10){ return n + '0'; }else{ return n - 10 + 'A'; } } void convert(int n,int k){ vector<int> answer; while(n != 0){ answer.push_back(intToChar(n % k)); n /= k; } for(int i = answer.size() - 1;i >= 0;i-- ){ printf("%c",answer[i]); } printf("\n"); } int main(){ int n,k; while(scanf("%d%d",&n,&k) != EOF){ convert(n,k); } return 0; }