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 dann at 2005-11-18 13:50:41 on Problem 1012
#include <stdio.h>
int k=0;

int main()
{
	scanf("%d",&k);
	while(k!=0)
	{
		int n=2*k;
		long a=0,b=0,m=k,c=k;
		while(1)
		{
			b=(n-1+m+a)%n;
			if(b>=0&&b<=k-1)
			{
				m++;
				a=0;
				c=k;
				n=2*k;
				continue;
			}
			if(b>=n-1) a=0;
			else a=b;
			n--;
			c--;
			if(c==0)
				break;
		}
		printf("%d\n",m);
		scanf("%d",&k);
	}
	return 1;
}

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