提交时间:2024-08-19 23:05:34
运行 ID: 168150
#include <bits/stdc++.h> using namespace std; int charzv(char ch) { if (isdigit(ch)) { return ch - '0'; } return toupper(ch) - 'A' + 10; } char vzchar(int v) { if (v < 10) { return '0' + v; } return 'A' + v - 10; } string jzzh(const string& n, int fbase, int tbase) { int jz10 = 0; for (char d : n) { jz10 = jz10 * fbase + charzv(d); } if (jz10 == 0) { return "0"; } string s; while (jz10 > 0) { s += vzchar(jz10 % tbase); jz10 /= tbase; } reverse(s.begin(), s.end()); return s; } int main() { int k, n, l; while (cin >> k >> n >> l) { string kr = to_string(n); string lr = jzzh(kr, k, l); cout << lr << endl; } return 0; }