1 条题解

  • 1
    @ 2024-7-25 13:27:00

    参考答案:

    #include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    
    using namespace std;
    
    vector<int> div(vector<int>& A, int b, int& t)
    {
        vector<int> C;
    
        for (int i = 0; i < A.size(); ++i)
        {
            t = t * 10 + A[i];
            C.push_back(t / b);
            t %= b;
        }
    
        reverse(C.begin(), C.end());
        while (C.size() > 1 && C.back() == 0) C.pop_back();
    
        return  C;
    }
    int main()
    {
        int b, t = 0;
        string a;
        vector<int>A;
    
        cin >> a >> b;
    
        for (int i = 0; i < a.size(); ++i) A.push_back(a[i] - '0');
        vector<int>C = div(A, b, t);
        for (int i = C.size() - 1; i >= 0; --i) cout << C[i];
    
        cout << endl;
        cout << t << endl;
    
        return 0;
    }
    
    • 1

    信息

    ID
    68
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    4
    已通过
    1
    上传者