Topic describes

In this case, calculate A/B, where A is A positive integer with no more than 1000 digits and B is A positive integer with 1 digit. You need to output the quotient Q and remainder R so that A=B×Q+R is true.

Input format: Enter A and B in A row, separated by 1 space.

Output format: Output Q and R in one line, separated by 1 space.

Example Value: 123456789050987654321 7 Example value: 17636684150141093474 3

Thought analysis

Subject investigation division has high precision, the common algorithms are simulated column vertical (not yet), Newton, partition division division (now also won’t 😂), today I also is the first attempt to simulate high precision manual division division simulation process, first remove each use to B, the first need special judgment, if only one output is not zero or digits, Otherwise times 10 plus the next digit, until the last digit is remainder

AC code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string A;
    int B,Q,R;
    cin>>A>>B;
    int len=A.length();
    Q=(A[0] -'0')/B;
    R=(A[0] -'0')%B;
    if(Q! =0||len==1)
        cout<<Q;
    for(int i=1; i<len; i++) { Q=(R*10+A[i]-'0')/B;
        cout<<Q;
        R=(R*10+A[i]-'0')%B;
    }
    cout<<' '<<R;
    return 0;
}
Copy the code

Conclusion comprehension

Set a flag: June 5 before brush a linked list related questions continue to make persistent efforts, hard brush questions 😁