#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<list>
#include<cstdlib>
#include<cstring>
using namespace std;
int main(){
int t,n;
cin>>t;
while(t--){
int k=2;
cin>>n;
list<int>blist;
list<int>::iterator it;
for(int i=1;i<=n;i++){
blist.push_back(i);
}
while(blist.size()>3){
int num=1;
for(it=blist.begin();it!=blist.end();){
if(num++%k==0){
it=blist.erase(it);
}else{
it++;
}
}
if(k==2){
k=3;
continue;
}else{
k=2;
continue;
}
//k==2?k=3:k=2;
}
for(it=blist.begin();it!=blist.end();it++){
if(it!=blist.begin()){
cout<<" ";
}
cout<<*it;
}
cout<<endl;
}
return 0;
}
STL-链表-士兵队列
最新推荐文章于 2024-08-24 21:01:27 发布