提交时间:2024-08-19 22:56:07

运行 ID: 168134

#include <bits/stdc++.h> using namespace std; string jzzh(int n, int base) { if (n == 0) { return "0"; } string d = "0123456789ABCDEF"; string res; while (n > 0) { res += d[n % base]; n /= base; } reverse(res.begin(), res.end()); return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int k, n, l; while (cin >> k >> n >> l) { int jzs10 = 0; int base = 1; while (n > 0) { jzs10 += (n % 10) * base; base *= k; n /= 10; } cout << jzzh(jzs10, l) << '\n'; } return 0; }