11 solutions

  • 1
    @ 2025-3-29 22:12:05

    大佬的做法都好复杂,这个难道不是进制转换的模板题目吗

    #include <bits/stdc++.h>
    #define endl '\n'
    using namespace std;
    typedef pair<int, int> PII;
    using ll = long long;
    using ULL = unsigned long long;
    const int N = 1e7 + 5;
    int n, m; 
    inline void solve() {
        cin >> n >> m;
        string ans = "";
        while (n) {
            auto x = n%m;
            if(x>=10&&x<=36) ans +='A'+x-10;
            else ans += x+'0';
            n/=m;
        }
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    int main() {
        ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int _ = 1;
        //int _; cin >> _;
        while (_--) solve();
        return 0;
    }
    
    

    Information

    ID
    288
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    4
    Tags
    # Submissions
    127
    Accepted
    57
    Uploaded By