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

Re:终于不打表AC,282ms,放出代码,求更快的解法……

Posted by only_520 at 2011-04-29 20:38:32 on Problem 1012
In Reply To:终于不打表AC,282ms,放出代码,求更快的解法…… Posted by:alexneko at 2008-07-12 16:14:45
> #include <stdio.h>
> 
> /*#include <time.h>*/
> 
> #include <string.h>
> 
> 
> 
> int main()
> 
> {
> 
> 	int arr[15];
> 
> 	memset(arr,0,15*sizeof(int));
> 
> 	while(1)
> 
> 	{
> 
> 	int k,m=0;
> 
> 	scanf("%d",&k);
> 
> 	if(k==0)break;
> 
> 
> 	if(arr[k]==0)
> 
>         {
> 
> 		
> 
> 	while(1)
> 
> 	{
> 
> 		m++;
> 
> 		int bad=k*2,now=0;
> 
> 
> 		while(1)
> 
> 		{
> 
> 			now=(now+m-1)%bad+1;
> 
> 			if(now>k)
> 
> 			{
> 
> 				bad--;
> 
> 				now--;
> 
> 			}
> 
> 			else
> 
> 				break;
> 
> 		}
> 
> 		
> 		if(bad==k){arr[k]=m;break;}
> 
> 	}
> 
> 	}
> 
> 
> 	printf("%d\n",arr[k]);
> 
> 		
> 
> 	}
> 
> 	/*printf("%f\n",(float)clock()/CLOCKS_PER_SEC);*/
> 
> }

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