提交时间:2023-08-21 20:05:11
运行 ID: 99069
#include<iostream> #include<string> #include<deque> using namespace std; int main() { string n; int k, l; while (cin >> k >> n >> l) { deque<int>v; int s{}; for (int i{}; i < n.size(); i++) if (isupper(n[i])) s = s * k + n[i] - 'A' + 10; else s = s * k + n[i] - '0'; do v.push_front(s % l); while (s /= l); for (auto x : v) if (x > 9) cout << char(x - 10 + 'A'); else cout << x; cout << endl; } return 0; }