hdu1276

#include
using namespace std;

int t,n,sum=0;
bool judge[5005];

int main(){
    cin>>t;
    for(int cishu=1;cishu<=t;cishu++){
        cin>>n;memset(judge,false,sizeof(judge));sum=n;
        for(int i=1;sum>3;i++){
            if(i%2==1){
                int p=0;
                for(int j=1;j<=n;j++){
                    if(judge[j]==false){
                        p++;
                        if(p%2==0)judge[j]=true,sum--;
                    }
                }
            }
            else if(i%2==0){
                int p=0;
                for(int j=1;j<=n;j++){
                    if(judge[j]==false){
                        p++;
                        if(p%3==0)judge[j]=true,sum--;
                    }
                }
            }
        }
        cout<<1;
        for(int j=2;j<=n;j++){
            if(judge[j]==false)cout<<" "<<j;
        }
    cout<<endl;    
    }
}

你可能感兴趣的:(acwing,水题,数据结构)