VFDIV - Very Fast Division
Given two positive integers A and B, compute the unique Q and R such that A = Q * B + R and 0 <= R < B. That is, compute the quotient, Q, and the remainder, R, of A divided by B.
Input
The first line contains a single integer T (1 <= T <= 10), indicating the number of test cases. Each test case contains a single line with A and B separated by a space. A and B will be positive integers with no more than 100,000 decimal digits with no leading zeroes.
Output
For each test case output a single line containing Q and R separated by a space.
Example
Input: 3
128 10
4320 321
1234567890098765432112345678900987654321 98765432100123456789 Output: 12 8
13 147
12499999887078125001 82208718896223572532
Note: Submissions that are little more than using your language's built in big integer library are subject to disqualification without notice.
hide comments
Mark Gordon:
2015-01-26 17:14:45
Also, see http://www.spoj.com/problems/VFMUL/ Last edit: 2013-01-05 06:41:31 |
|
Mark Gordon:
2015-01-26 17:14:45
Try https://www.spoj.com/problems/FDIV/ first |
Added by: | Mark Gordon |
Date: | 2013-01-05 |
Time limit: | 10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 PIKE |