2 solutions

  • 0
    @ 2026-8-24 15:41:50
     #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        int a,b;
        string s;
        cin>>a>>b;
        while(a>0)
        {
            int o=a%b;
            if(o>=10){
                s+='A'-10+o;
            }else{
                s+='0'+o;
            }
            a/=b;
        }
        reverse(s.begin(),s.end());
        cout<<s;
        return 0; 
    }
    

    CCF4302CCF4302

    • 0
      @ 2026-7-9 15:54:09
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int N,R;
          cin>>N>>R;
          string ans;
          while(N>0){
              int n=N%R;
              char c;
              if(n < 10) c=n +'0';
              else c=n-10+'A';
              ans+=c;
              N/=R;
          }
          reverse(ans.begin(), ans.end());
          cout << ans;
          return 0;
      }
      
      • 1

      Information

      ID
      1160
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      # Submissions
      33
      Accepted
      14
      Uploaded By