3 条题解

  • 1
    @ 2023-10-6 21:22:21
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<cstdio>
    #include<cmath>
    #include<algorithm>
    #include<stack>
    using namespace std;
    stack<int>st;
    string nums = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n,x;
    int main(){
    	cin >> n >> x;
    	while(n/x){
    		st.push(n%x);
    		n = n/x;
    	} 
    	st.push(n%x);
    	while(!st.empty()){
    		cout << nums[st.top()];
    		st.pop();
    	}
    	return 0;
    }
    
    • 1
      @ 2022-9-17 20:38:39
      #include<iostream>
      using namespace std;
      long long n,a,i,s,x,q,b[100],j;
      char cc;
      int main()
      {
          cin>>n;
          a=1;
          s=0;
          i=1;
          cin>>q;
          while(n!=0)
          {
              x=n%q;
              b[i]=x;
              n=(n-x)/q;
              i++;
          }
          for(j=i-1;j>=1;j--)
          {
          	if(b[j]<10) 
              cout<<b[j];
              else 
              {
              	cc=b[j]-10+65;
              	cout<<cc;
      		}
          }
          if(i==1)
              cout<<"0";
          return 0;
      }
      
      • 0
        @ 2023-10-18 19:24:33
        #include <bits/stdc++.h>
        using namespace std;
        string dec_to_x(int num,int x)
        {
        	string d = "";
        	int s = num;
        	while (true)
        	{
        		int p = s%x;
        		if (p >= 10)
        		{
        			p += 55;
        		}
        		else
        		{
        			p += 48;
        		}
        		d = d + (char)p;
        		s = (s-(s%x))/x;
        		if (s == 0)
        		{
        			break;
        		}
        	}
        	string a = "";
        	for (int i = d.size()-1;i >= 0;i--)
        	{
        		a = a + d[i];
        	}
        	return a;
        }
        int main()
        {
        	int dec,x;
        	cin>>dec>>x;
        	cout<<dec_to_x(dec,x)<<endl;
        	return 0;
        }
        
        • 1

        信息

        ID
        7242
        时间
        1000ms
        内存
        128MiB
        难度
        2
        标签
        递交数
        15
        已通过
        13
        上传者