2 条题解

  • 1
    @ 2024-5-6 21:38:15
    #include <bits/stdc++.h>
    using namespace std;
    string n;
    long long binary1(string x,int y){
    	long long sum=0,t=1;
    	for (int i=(int)n.size()-1;i>=0;i--){
    		if (isalpha(n[i]))sum+=(n[i]-'A'+10)*t;
    		else if (isdigit(n[i]))sum+=(n[i]-'0')*t;
    		t*=y;
    	}
    	return sum;
    }
    string binary2(long long x,int y){
    	if (x==0)return "0";
    	string rep;
    	while (x>0){
    		int g=x%y;
    		if (g<10)rep+=(g+'0');
    		else rep+=((char)g-10+'A');
    		x/=y;
    	}
    	reverse(rep.begin(),rep.end());
    	return rep;
    }
    int main(){
    	cin>>n;
    	cout<<binary2(binary1(n,2),8);
    	return 0;
    }
    
    • -1
      @ 2024-4-14 19:13:52
      #include <bits/stdc++.h> 
      using namespace std;
      #define ll long long
      #define s string
      #define c char
      #define co cout
      #define ci cin
      #define b bool
      #define re return
      
      int main(){
          ios::sync_with_stdio(0);
          cin.tie(0);
          cout.tie(0);
          cout<<62;
          return 0;
      }
      
      • 1

      【基础】二进制转换八进制

      信息

      ID
      290
      时间
      1000ms
      内存
      16MiB
      难度
      1
      标签
      递交数
      38
      已通过
      28
      上传者