#include<bits/stdc++.h> #define READ freopen("in.txt","r",stdin); #define WRITE freopen ("out.txt","w",stdout); using namespace std; int main() { // READ // WRITE queue<int >Q; queue<int>r; int n; while(cin>>n) { if(n==0) break; if(n==1) { cout<<"Discarded cards:"<<endl; cout<<"Remaining card: 1"<<endl; continue; } while(!Q.empty()) Q.pop(); while(!r.empty()) r.pop(); for(int i=1; i<=n; i++) r.push(i); while(r.size()>1) { int u=r.front(); Q.push(u) ; r.pop(); int x=r.front(); r.pop(); r.push(x); } int c=0; cout<<"Discarded cards: "; while(!Q.empty()) { cout<<Q.front(); c++; if(c<n-1) cout<<", "; Q.pop(); } cout<<endl; cout<<"Remaining card: "<<r.front()<<endl; } return 0; }
About Me
About Me :
I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).
Skills
Skills
• Javascript •Typescript •Python •C •Java
•ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs
• Git • Docker • Jira • Visual Studio Code • Slack
শনিবার, ১৭ জানুয়ারী, ২০১৫
UVA SOLUTION:10935 - Throwing cards away I
এতে সদস্যতা:
মন্তব্যগুলি পোস্ট করুন (Atom)
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন