标签:
Description
Input
Output
Sample Input
Sample Output
#include<iostream> #include<list> using namespace std; int main(){ int t;cin>>t; while(t--){ int n;cin>>n; list<int>x; for(int i=1;i<=n;i++)x.push_back(i); int i,t1=0; while(n>3){ i=1; for(list<int>::iterator it=x.begin();it!=x.end();i++){ if(i%(2+t1)==0){it=x.erase(it);n--;} else it++; } t1=1-t1; } list<int>::iterator it=x.begin(); for(;it!=--(x.end());it++){ cout<<*it<<" "; } cout<<*it<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/demodemo/p/4678431.html