This problem requires calculation /, where A is not more than 1000 bit positive integer, B is a positive integer. You need to output quotient Q and a remainder R, such that A = B × Q + R & lt established.
Input formats:
Given in one row sequentially input A and B, separated by an intermediate space.
Output formats:
In a row are sequentially output Q and R, separated by an intermediate space.
Sample input:
123456789050987654321 7
Sample output:
17636684150141093474 3
--------------------------------------------------
借助字符串来还原最原始的除法公式
#include <stdio.h>
#include<string.h>
#include<iostream>
#include <math.h>
#include <malloc.h>
using namespace std;
main int () {
char A [1001];
CIN >> A;
int B;
CIN >> B;
int n-;
n-= strlen (A);
int TEMP = 0, In Flag = 0;
for (int I = 0; I <n-; I ++)
{
TEMP = (a [I] - '0') + 10 * TEMP; // if left at the front to add a number of division, a position corresponding to this time it should be a zero
if ( TEMP> = B)
{
COUT << (TEMP / B);
In Flag =. 1;
} the else IF (In Flag) {
COUT << "0"; // this step so only
} // should be short temp <b kind of situation
TEMP TEMP =% B;
}
IF (In Flag == 0) ///// dividend is smaller than the divisor, there is no circulation
{
COUT << "0";
}
COUT << "" << TEMP;
return 0;
}