#C1721. Distributing Chocolates

    ID: 44958 Type: Default 1000ms 256MiB

Distributing Chocolates

Distributing Chocolates

You are given a number of chocolates M and a number of children K. Your task is to distribute the chocolates equally among the children. Each child will receive \( \lfloor M/K \rfloor \) chocolates. The remaining chocolates, which is \( M \mod K \), will be kept by the shopkeeper.

For example, if there are 10 chocolates and 3 children, each child will get \(\lfloor10/3\rfloor = 3\) chocolates, and 1 chocolate remains.

You need to implement a program that reads several test cases from standard input. The first input line contains an integer \(T\) (the number of test cases), followed by \(T\) lines each containing two integers \(M\) and \(K\). For each test case, output the number of chocolates each child receives and the remaining chocolates, separated by a space.

inputFormat

The input is given via stdin in the following format:

T
M1 K1
M2 K2
... 
MT KT

Where:

  • T is the number of test cases.
  • Each test case consists of two integers M (the total number of chocolates) and K (the number of children).

outputFormat

For each test case, output a single line to stdout containing two integers separated by a space: the number of chocolates each child receives and the number of chocolates remaining with the shopkeeper.

## sample
6
10 3
25 4
99 10
0 1
100 1
100 1000
3 1

6 1 9 9 0 0 100 0 0 100

</p>