提交时间:2024-06-01 16:10:35

运行 ID: 150164

#include <bits/stdc++.h> using namespace std; int main() { int k, l; string n; cin >> k >> l >> n; int man = 0; for (char c:n) { man*= k; man += isdigit(c) ? c - '0' : c - 'A' + 10; } string ans; while (man > 0) { int what = man % l; char c = what < 10 ? what + '0' : what - 10 + 'A'; ans = c + ans; man /= l; } cout << ans << endl; return 0; }