The subject requires a A/b, where A is a positive integer that does not exceed 1000 bits, and B is a 1-bit positive integer. You need to output the quotient Q and the remainder r so that a = B * Q + R is set up.
Input format:
The input is given a and B in 1 rows, and the middle is separated by 1 spaces.
Output format:
In 1 rows, output Q and R in turn, separated by 1 spaces in the middle.
Input Sample:
123456789050987654321 7
Sample output:
17636684150141093474 3
#include <iostream>
#include <string>
using namespace Std;
int main () {
String Str,ans;
int n,d = 0;
CIN >> str >> n;
for (int i = 0; I <= str.size ()-1; i++) {
int current = d * + (str[i]-' 0 ');
Ans + = (current/n+ ' 0 ');
d = current% n;
}
for (int i = (ans[0] = = ' 0 ' && ans.size ()!=1)? 1:0; i < ans.size (); i++)
cout << ans[i];
cout << "" << D;
return 0;
}
Is that short enough to write? :)
1017. A divided by B (20)