
#include<iostream> |
#include<queue> |
#include<cstdio> |
using namespace std; |
queue<int>q; |
int main() |
{ |
int n; |
while(cin>>n&&n!=0) |
{ cout<<"Discarded cards:"; |
for(int i=1;i<=n;i++) |
{ |
q.push(i); |
} |
while(!q.empty()) |
{ |
if(q.size()==1) break; |
if(q.size()==2) cout<<" "<<q.front(); |
else |
{cout<<" "<<q.front()<<',';} |
q.pop(); |
q.push(q.front()); |
q.pop(); |
} |
printf("\n"); |
printf("Remaining card:"); |
cout<<" "<<q.front()<<endl; |
q.pop(); |
} |
return 0; |
} |



