3 条题解

  • 0
    @ 2025-3-18 20:47:35
    #include <bits/stdc++.h>
    #define endl '\n'
    using namespace std;
    typedef pair<int,int> aII;  
    using ll = long long;
    using ULL = unsigned long long;
    const int N = 1e6+5;
    
    ll res, m;
    string ans;
    inline void solve() { 
        cin >> res >> m;
        while (res) {
            auto x = res % m;
            if (x >= 10 && x <= 15) ans += x + 'A' - 10;
            else ans += x + '0';
            res /= m;
        } 
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    int main() { 
        ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int _ = 1; 
        //int _; cin >> _;
        while (_--) solve();
        return 0;
    }
    
    • 0
      @ 2025-2-6 11:54:58
      // https://dashoj.com/p/95
      #include <bits/stdc++.h>
      
      using namespace std;
      
      int s, base;
      
      int main() {
      	cin >> s >> base;
      	char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      	string result;
      	while (s != 0) {
      		result.push_back(digits[s % base]);
      		s /= base;
      	}
      	reverse(result.begin(), result.end());
      	cout << result << endl;
      	return 0;
      }
      
      • 0
        @ 2024-4-10 18:01:10

        ``

        using namespace std;
        
        int s,base;
        string p="0123456789ABCDEF";
        string ans;
        int main()
        {
        	cin>>s>>base;
        	while(s){
        		ans.push_back(p[s%base]);
        		s/=base;
        	}
        	reverse(ans.begin(),ans.end());
        	cout<<ans;
        	return 0;
        }
        
        • 1

        信息

        ID
        95
        时间
        1000ms
        内存
        256MiB
        难度
        4
        标签
        递交数
        468
        已通过
        211
        上传者