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

高手们,你们的本机程序是怎么写的?我想打表但程序慢得无话说

Posted by Exile_oi at 2006-07-04 16:00:39 on Problem 1012
#include <iostream>
using namespace std;
int out[15];
bool sj(int& k,int& m)
{
  int m0,n=k<<1;
  memset(out,0,n*sizeof(int));
  int i,j,*p=out-1,*end=out+n,*mid=out+k;
  for(i=0;i!=k;++i)
  {
    m0=m%(n-i);
    if(m0==0) m0=n;
    for(j=0;j!=m0;++j)
      do
        if(++p==end) p=out;
      while(*p);
    *p=1;
    if(p<mid) return false;
  }
  return true;
}
int main()
{
  int m,k;
  for(;;)
  {
    cin>>k;
    if(k==0) return 0;
    for(m=2;;++m)
      if(sj(k,m))
      {
        cout<<m<<endl;
        break;
      }
  }
}

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