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 sunmoonstar_love at 2005-08-25 23:08:26 on Problem 1061
In Reply To:我用相对运动去做! 但是超时!!!现附上我的程序!! 请各位高手指点下可以怎样修改!!先谢了!! Posted by:flyman at 2005-08-25 22:16:34
> #include<stdio.h>
> #include<math.h>
> void main()
> {
> 	int i;
> 	long x,y,m,n,l;
> 	long v,sum,temp;
> 	scanf("%d%d%d%d%d",&x,&y,&m,&n,&l);
> 	if(m==n) printf("Impossible\n");
> 	else
> 	{
> 		if(m>n) 
> 		{
> 			v=m-n;
> 			temp=x;
> 			x=y;
> 			y=temp;
> 		}       //y追x;x相对y静止
> 		else v=n-m;
> 		sum=y;
> 		i=0;
> 		while(1)
> 		{
> 			sum+=v;
> 			i++;
> 			if(sum%l==x)
> 			{
> 				printf("%d\n",i);
> 				break;
> 			}
> 			else if(sum%l==y)
> 			{
> 				printf("Impossible\n");
> 				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