10 solutions

  • 0
    @ 2022-1-2 22:59:09

    本人蒟蒻,各位大佬轻点喷

    #include<bits/stdc++.h>
    using namespace std;
    
    stack<int> s;
    char arr[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    void dfs(int a,int b)
    {
    	if(a>b)
    	{
    		int num=a%b;
    		a=a/b;
    		s.push(arr[num]);
    		dfs(a,b);
    	}
    	else
    	{
    		s.push(arr[a]);
    	}
    }
    
    int main()
    {
    	int a,b;
    	cin>>a>>b;
    	dfs(a,b);
    	while(!s.empty())
    	{
    		char c;
    		c=s.top();
    		cout<<c;
    		s.pop();
    	}
    	return 0;
    }
    

    Information

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