提交时间:2024-04-06 08:36:57
运行 ID: 141581
#include <bits/stdc++.h> using namespace std; stack <long long> jinzhi; int main() { int n , m; cin >> n >> m; if (n == 0) { cout << 0; } else { while (n > 0) { jinzhi.push(n % m); n /= m; } while (!jinzhi.empty()) { if (jinzhi.top() >= 10) { putchar((char)(jinzhi.top() - 10 + 'A')); } else { cout << jinzhi.top(); } jinzhi.pop(); } } return 0; }