UVa 10935 - Throwing cards away I

10935 - Throwing cards away I

 * http://acm.uva.es/p/v109/10935.html

Summary
Simulate the problem as described. You can use a queue to efficiently simulate, but it's not necessary.

Explanation
No explanations needed, a pure simple simulation problem.

Gotcha's

 * Make sure you handle n=1 correctly.

Input
1 7 19 10 6 0

Output
Discarded cards: Remaining card: 1 Discarded cards: 1, 3, 5, 7, 4, 2 Remaining card: 6 Discarded cards: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 4, 8, 12, 16, 2, 10, 18, 14 Remaining card: 6 Discarded cards: 1, 3, 5, 7, 9, 2, 6, 10, 8 Remaining card: 4 Discarded cards: 1, 3, 5, 2, 6 Remaining card: 4