#P5051. Kids Team Distribution
Kids Team Distribution
Kids Team Distribution
You are given three integers M
, N
, and K
where:
M
is the total number of kids.N
is the number of teams.K
is the number of kids to add to a team in each step.
The distribution starts by placing \(K\) kids in the first team, then the second team, and so on up to the \(N^\text{th}\) team. When the \(N^\text{th}\) team is reached, the direction reverses and you continue by placing \(K\) kids in the \((N-1)^\text{th}\) team, then the \((N-2)^\text{th}\) team, and so on until you reach the first team again. Then the direction reverses once more (starting from the second team) and the process continues in a zigzag manner.
If at any point the remaining number of kids is less than \(K\), then all the remaining kids are placed in the current team and the process terminates.
Your task is to output the final number of kids in each team after the process ends.
inputFormat
The input consists of a single line containing three space-separated integers: M
N
K
.
\(1 \leq M, N, K \leq 10^9\)
outputFormat
Output a single line containing N
space-separated integers, where the \(i^\text{th}\) integer represents the final number of kids in the \(i^\text{th}\) team.
sample
10 3 3
3 4 3