#K62137. Token Distribution Problem

    ID: 31465 Type: Default 1000ms 256MiB

Token Distribution Problem

Token Distribution Problem

You are given several test cases. In each test case, there are two integers \(M\) and \(P\) representing the total number of tokens and the number of participants respectively. Your task is to determine how many tokens each participant gets, and how many tokens remain with Varun after the distribution.

The distribution is performed as follows:

Each participant receives \(\lfloor M/P \rfloor\) tokens, and the remaining tokens are given to Varun. That is, the remainder is calculated as \(M \bmod P\).

For example, if \(M=10\) and \(P=3\), each participant gets \(\lfloor 10/3 \rfloor = 3\) tokens and Varun gets \(10 \bmod 3 = 1\) token.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (T), the number of test cases. This is followed by (T) lines; each line contains two integers (M) and (P) separated by a space.

outputFormat

For each test case, output two integers separated by a space; the first integer is the number of tokens each participant receives (i.e., (\lfloor M/P \rfloor)) and the second integer is the number of tokens left with Varun (i.e., (M \bmod P)). Each result should be printed on a new line.## sample

3
10 3
15 4
0 5
3 1

3 3 0 0

</p>