提交时间:2024-03-31 12:39:23

运行 ID: 44571

#include <bits/stdc++.h> using namespace std; string turn(long long x, int N, string res="") { if(x == 0) { reverse(res.begin(),res.end()); return res; } if(x%N>=10) { res += (char)(x%N-10+'A'); } else { res += (char)(x%N+'0'); } return turn(x/N,N,res); } int main() { long long x, N; cin >> x >> N; cout << turn(x, N); return 0; }