10 solutions

  • 0
    @ 2022-1-2 21:47:05
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int n,m,cnt;
    int a[105];
    char b;
    int main ()
    {
        cin>>n>>m;
        cnt=0;
        int k=n;
        while(k>0)
        {
        	a[cnt]=k%m;
        	k-=a[cnt];
        	k/=m;
        	cnt++;
    	}
    	for(int i=cnt-1;i>=0;--i)//倒序输出 
    	{
    		if(a[i]>=10)
    		{
    			b='A'+a[i]-10;
    			cout<<b;
    		}
    		else
    		{
    			cout<<a[i];
    		}
    	}
        return 0;
    }
    

    Information

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