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:高手们,看看这有啥错误吧??(1061题)

Posted by pladene at 2003-11-26 18:57:03
In Reply To:高手们,看看这有啥错误吧??(1061题) Posted by:999999999 at 2003-11-26 16:59:39
这种方法还超时。建议看看扩展欧几里德算法
> #include<stdio.h>
> void main()
> {
> 	int i;
> 	long b,c,x,y,m,n,L;
> 	unsigned long a;
> 	scanf("%d%d%d%d%d",&x,&y,&m,&n,&L);
> 	if(m>n)
> 		a=m*L;
> 	else
> 		a=n*L;
> 	for(i=1;i<=a-1;i++)
> 	{
> 		b=m*i+x;	
> 		c=n*i+y;
> 		if((b-c)%L==0)
> 			break;
> 	}
> 	if(i==a)
> 		printf("Impossible\n");
> 	else
> 		printf("%d\n",i);
> }

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