#include<iostream>
using namespace std;
int main(){
int person[5005]={0};
int n;
cin >> n;
while (n--){
int num,numtemp,i;
cin >> num;
numtemp = num;
for ( i = 0; i < num; i++){
person[i] = i + 1;//提到外面去会不会有时间有减少?增加效率?
}
while (numtemp>3)
{
i = 0;int j = 0,k=0;
while (i < num)
{
//if (numtemp <= 3) break;写上即答案错误!
if (person[i])
{
j++;
if (j % 2 == 0){
person[i] = 0; numtemp--;
j = 0;
}
i++;
}
else
i++;
}
if (numtemp <= 3) break;
i = 0;
while (i < num)
{
//if (numtemp <= 3) break;写上即答案错误
if (person[i])
{
k++;
if (k % 3 == 0){
person[i] = 0; numtemp--;
k = 0;
}
i++;
}
else
i++;
}
}
int m = 1;
for (i = 0; i < num; i++){
if (person[i]&&m){
cout << person[i];
m = 0;
}
else if (person[i]){
cout << " " << person[i];
}
}
cout << endl;
}
return 0;
}
不能在数数的中途判断人数是否少于3人!!,应当一遍数完后再判断