#include<iostream>
#include<vector>
#include<string>
#include<type_traits>
#include<sstream>
#include<tuple>
#include<bitset>
#include<regex>
#include<set>
#include<queue>
using namespace std;
int main(){
int n;
while (cin >> n){
if (n == 0) break;
queue<int> q;
for (int i = 1; i <= n; i++) q.push(i);
vector<int> discard;
bool flag = true;
while (q.size() > 1){
int t = q.front();
q.pop();
if (flag){
discard.push_back(t);
flag = !flag;
}
else{
q.push(t);
flag = !flag;
}
}
cout << "Discarded cards:";
for (int i = 0; i < discard.size(); i++){
cout << ' '<<discard[i];
if (i < discard.size() - 1) cout << ",";
}
cout << endl;
cout << "Remaining card: " << q.front() << endl;;
}
//system("pause");
return 0;
}
UVA 10935
最新推荐文章于 2020-12-09 23:31:13 发布