提交时间:2024-04-06 09:29:43

运行 ID: 141656

#include <bits/stdc++.h> using namespace std; stack<char> stk; char a[37] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; int main(){ int n, d; cin >> n >> d; while(n){ stk.push(a[n % d]); n /= d; } if(stk.empty()){ cout << 0; } else { while(!stk.empty()){ cout << stk.top(), stk.pop(); } } return 0; }