#C8385. Balanced Distribution of Participants
Balanced Distribution of Participants
Balanced Distribution of Participants
You are given a number of participants P and a number of groups G. Your task is to distribute the participants among the groups so that the difference in the number of participants between any two groups is at most 1.
The distribution should be output in non-decreasing order. In case P is less than G, some groups may have 0
participants.
Mathematically, if we let \(b = \lfloor P/G \rfloor\) and \(r = P \mod G\), then exactly \(r\) groups will have \(b+1\) participants and the remaining \(G-r\) groups will have \(b\) participants. The final answer must be sorted in ascending order.
inputFormat
The first line of input contains an integer T representing the number of test cases.
Each of the next T lines contains two integers P and G separated by a space, where P is the number of participants and G is the number of groups.
Input is provided via standard input (stdin).
outputFormat
For each test case, output a single line containing G integers separated by a space representing the number of participants in each group in non-decreasing order.
Output should be written to standard output (stdout).
## sample2
10 3
15 4
3 3 4
3 4 4 4
</p>