#35612: jjjj


yp11151230@yphs.tp.edu.tw (909-42蔡亞儒)

學校 : 臺北市私立延平高級中學
編號 : 197211
來源 : [150.129.72.232]
最後登入時間 :
2025-07-09 18:05:16

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(cin >> n &&  n ){
        queue<int> Q;
        int card[100]={0},end=0;

        for(int i=1;i<=n;i++) Q.push(i);
        cout<<"Discarded cards: ";
        while(Q.size()>1){
            cout<<Q.front();
            if(Q.size()!=2)cout<<", ";
            card[end++]=Q.front();
            Q.pop();
            Q.push(Q.front());
            Q.pop();
        }
        cout<<"\nRemaining card: "<<Q.front()<<'\n';
    }
}