Submit | All submissions | Best solutions | Back to list |
FDIV - 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 10,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
Added by: | Mark Gordon |
Date: | 2013-01-05 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
2013-05-12 02:14:42 [Lakshman]
@Amit although its too late there is Little modification in your code and its working fine. http://ideone.com/F11Vus |
|
2013-01-15 13:54:49 Amit
I dont know why my code is showing NZEC :( http://ideone.com/RzsVNu any help Last edit: 2013-01-15 13:55:41 |
|
2013-01-12 11:13:30 Francky
It's true for MUL too ! There should have been a selected choice of language. |
|
2013-01-11 04:33:27 Mitch Schwartz
Trivial Pike solution gets AC in VFDIV. |
|
2013-01-10 08:31:04 :D
If you can make trivial solutions in some languages the it should be tutorial. Moving it. |
|
2013-01-06 08:56:05 abdelkarim
by java it is tutorial . Last edit: 2013-01-06 19:51:46 |
|
2013-01-05 23:59:20 Mark Gordon
The problem is not about getting accepted |
|
2013-01-05 12:50:36 (Tjandra Satria Gunawan)(曾毅昆)
1 line, 71B of python code CAN get Accepted! |