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

不能直接模N,大于N才模N,小于等于时不能模。

Posted by busycai at 2006-10-03 17:20:24 on Problem 2657
In Reply To:HELP Posted by:zsl2007 at 2005-12-14 19:02:53
> 我测试是正确的阿。怎么总是wrong answer?
> 我的程序如下:
>  #include<stdio.h>
> int sort(int n,int z,long k,int m,int *mm)
>  {
> 	int i,j;
>     for(i=0;i<=n;i++)
> 		{
> 			for(j=1;j<=m;j++)
> 			 if((1+i*k)%n==mm[j])
> 			  return 0;
> 			  
> 			  if(z==(1+i*k)%n)
> 			    return 1;
> 	  }		    
> 	}
> int main()
> {
> 	 int n,z,m,i;
> 	 int k;
> 	 int mm[1000];
>   scanf("%d%d%d",&n,&z,&m);
>      for(i=1;i<=m;i++)
>        {scanf("%d",&mm[i]);
>          if(mm[i]==n)
>           mm[i]=0;
>         }  
>         if(m==0) {printf("1\n");return 0;}
>           if(z==n)  z=0;            
>      for(k=1;k<n;k++)
> 	     if(sort(n,z,k,m,mm))
> 	      break;
>                                
> 	  printf("%d\n",k);
>        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