UVa 10935

From Algorithmist
Jump to navigation Jump to search

10935 - Throwing cards away I[edit]

Summary[edit]

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

Explanation[edit]

No explanations needed, a pure simple simulation problem.

Gotcha's[edit]

  • Make sure you handle n=1 correctly.

Solutions[edit]

Input[edit]

1
7
19
10
6
0

Output[edit]

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