标签:
Input
Output
Sample Input
Sample Output
#include<cstdio> #include<cstring> #include<iostream> using namespace std; int s[5001]; int main() { int T; cin>>T; while(T--) { int i,j,k,m; cin>>m; memset(s,0,sizeof(s)); for(i=1;i<=m;i++) s[i]=i; k=2; while(m>3) { if(k==2){ for(j=1,i=1;i<=m;i++) { if(i%k==0) continue; else s[j++]=s[i]; } m=j-1; k=3; } else{ for(j=1,i=1;i<=m;i++) { if(i%k==0) continue; else s[j++]=s[i]; } m=j-1; k=2; } } for(i=1;i<=m;i++) { if(i<m) cout<<s[i]<<" "; else cout<<s[i]<<endl; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/yilihua/p/4674634.html