Timovi
Time limit1sMemory limit64 MB
Kids are dealt into N teams in a bouncing 1..N..1 order, K per visit, until fewer than K remain; report each team's final count.
- Level
Medium4 of 10
- Topics
- Math, Simulation, Implementation, Array
- Solved
- No attempts yet
Problem
You split kids into teams. First you put kids into the first team, then kids into the second team, and so on up to the th team. After the th team you turn around and keep putting kids into each team, going from the th team down to the first team. After the first team you turn around again, continue from the second team up to the th team, and repeat until no kids are left to hand out.
For example, with three teams the kids go into the teams in this order: 1, 2, 3, 2, 1, 2, 3, and so on.
If fewer than kids are left when a team comes up, that team takes every remaining kid and the process ends.
Report how many kids each team holds once the process ends.
Input
The first line contains the integers , and (, ).
Output
Print the number of kids in each of the teams on a single line, from the first team to the th team, separated by single spaces.