提交时间:2024-08-19 23:13:56

运行 ID: 168159

#include<bits/stdc++.h> using namespace std; char a[10000]; int main(){ int k, n, l; while(cin >> k >> n >> l){ long long w = 1, sum = 0; while(n != 0){ int r = n % 10; n /= 10; sum += r * w; w *= k; } int i = 1, cnt = 0; while(sum != 0){ int r = sum % l; sum /= l; if(r < 10) a[i] = char(r + 48); else a[i] = char(r - 10 + 'A'); cnt++; i++; } for(int i = cnt; i >= 1; i--){ cout << a[i]; } cout << endl; } return 0; }