#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
while(cin>>N && N!=0){
queue<int> card;
vector<int> discard;
for(int i=1; i<=N; ++i){
card.push(i);
}
while(card.size()>1){
discard.push_back(card.front());
card.pop();
card.push(card.front());
card.pop();
}
if(!discard.empty()){
cout<<"Discarded cards: "<<discard[0];
for(int i=1; i<discard.size(); ++i){
cout<<", "<<discard[i];
}
}
cout<<"\nRemaining cards: "<<card.front()<<"\n";
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: