1 solutions

  • 0
    @ 2026-11-15 12:38:05

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int a[50];
    void solve(int n, int b) {
        int i;
        for(i = 0; n > 0; i++) {
            a[i] = n % b; n /= b;
        }
        while(i > 0) {
            cout << a[i - 1];
            i--;
        }
        cout << endl;
    }
    int main() { 
        ios::sync_with_stdio(false);
        int t, n, b;
        cin >> t;
        while(t--) {
            cin >> n >> b;
            solve(n, b);
        }
        return 0;
    }
    
    • 1

    Information

    ID
    189
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By