-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10935.cpp
More file actions
30 lines (30 loc) · 713 Bytes
/
10935.cpp
File metadata and controls
30 lines (30 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bits/stdc++.h>
using namespace std;
int main() {
queue<int> q;
int i, k, n;
while (scanf("%d", &n) == 1) {
if (n == 0) return 0;
for (i = 1; i <= n; i++) q.push(i);
printf("Discarded cards:");
i = 0;
k = 0;
while (q.size() != 1) {
if (k == 0) {
if (i != 0) printf(",");
printf(" %d", q.front());
q.pop();
k = 1;
} else {
q.push(q.front());
q.pop();
k = 0;
}
i = 1;
}
puts("");
printf("Remaining card: %d\n", q.front());
q.pop();
}
return 0;
}