If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Read this line carefully " When the machine is switched on in the morning, with an empty output store, it immediately moves 1 coin into the output store. When that has been dispensed it will then move 2 coins, then 3, and so on until it reaches some preset limit k. It then recycles back to 1, then 2 and so on."
1. When output store empty then the machine move coin. At part move 1 coin, then 2 coins, then 3 coins, and so on. If moving coin exit the limit k then the machine move 1 coin, then 2 coins, and so on. (Remember that the machine move coin when output store is empty).
2. A student withdraw coin role: If x coins in output store, a student need y coin
a. If x==y then the student withdraw y coins and leave the student. Now output store is empty.
b. if x>y then the student withdraw y coins and leave the student. Now (x-y) coin in output store.
c. if x<y then the student withdraw y coins and the student rejoins the queue at the end.
Just simulate the process using a queue of objects that hold a student number and an amount of money remaining.
"Learning to love yourself is the greatest love of all" - Michael Masser and Linda Creed
Pay attention to the following points:
1) ...The amount remaining in the store is then available for the next student.
Here, the machine does not dispense additional coins. The next student takes whatever is left in the store.
2) In your output, all numbers must be right justified in a field of width 3. This is important to avoid a Presentation Error.