#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int B, N;
int main(){
cin >> N >> B;
vector<int> res;
while(N){
res.push_back(N % B);
N /= B;
}
for(int i = res.size() - 1; i >= 0; i--) cout << res[i] << ‘ ‘;
return 0;
}
原文:https://www.cnblogs.com/chickenleg/p/15138955.html