Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水进2000发代码纪念!

Posted by fanhqme at 2008-10-09 21:30:14 on Problem 3032
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator