1 solutions

  • 0
    @ 2026-11-2 1:04:04

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	int N, R;
    	cin >> N >> R;
    	string ans;
    	while (N > 0) {
    		int rem = N % R;
    		if (rem < 10) ans += char('0' + rem);
    		else ans += char('A' + rem - 10);
    		N /= R;
    	}
    	reverse(ans.begin(), ans.end());
    	cout << ans << endl;
    	return 0;
    }
    
    • 1

    Information

    ID
    3
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    7
    Accepted
    4
    Uploaded By