| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水进2000发代码纪念!#include <cstdio>
#include <string.h>
using namespace std;
int main()
{
int used[13],N,T,p;
scanf("%d",&T);
while (T--){
scanf("%d",&N);
memset(used,0,sizeof(used));
p=0;
for (int i=1;i<=N;i++){
for (int j=0;j<i;j++){p++;p%=N;
if (used[p])j--;
}
used[p]=i;
if (i!=N)for (int j=0;j<1;j++){p++;p%=N;
if (used[p])j--;
}
}
for (int i=0;i<N;i++)printf((i==N-1?"%d\n":"%d "),used[i]);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator