2 条题解

  • 1
    @ 2026-1-21 19:23:14
    #include<bits/stdc++.h>
    using namespace std;
    string c="0123456798ABCDEF";
    void f(int x,int m){
    	if(x/m)
            f(x/m,m);
    	cout<<c[x%m];
    }
    int main(){
    	int x,m;
    	cin>>x>>m;
    	f(x,m);
    	return 0;
    }
    
    • -1
      @ 2026-1-21 19:19:46
      #include <iostream>
      #include <string>
      #include <algorithm>
      using namespace std;
       
      int main() {
          long long X;
          int N;
          cin >> X >> N;
          if (X == 0) {
              cout << 0 << endl;
              return 0;
          }
          string result;
          while (X > 0) {
              long long remainder = X % N;
              if (remainder < 10) {
                  result += (char)('0' + remainder);
              } else {
                  result += (char)('A' + remainder - 10);
              }
              X = X / N;
          }
          reverse(result.begin(), result.end());
          cout << result << endl;
          return 0;
      }
      
      • @ 2026-1-28 20:49:21

        这么简单的题搞这么复杂 我直接一个差评!

    • 1

    信息

    ID
    7000
    时间
    1000ms
    内存
    128MiB
    难度
    3
    标签
    递交数
    10
    已通过
    7
    上传者