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 wwwww at 2005-11-19 19:58:08 on Problem 1061
#include<stdio.h>
#include<math.h>
void main()
{
	long x,y,m,n,l,t,u;
	long trsg,i,mcd;
	scanf("%d %d %d %d %d",&x,&y,&m,&n,&l);
	if(m<n){trsg=m;m=n;n=trsg;trsg=x;x=y;y=trsg;}
	if(m!=n)
	{int difmn=m-n,dif=abs(difmn-l);
	float quti=(float)(l/difmn);
	for(i=difmn;i>=1;i--)
	{if (difmn%i==0) if(l%i==0) {mcd=i;break;}
	}
	if((x-y)%mcd!=0||l>2000000000||m>2000000000||n>2000000000||x==y) printf("Impossible\n");
	else
	{
		if (quti>=10) 
			for(u=1;u<=2000000000;u++)
			{if((u*l+y-x)%(difmn)==0){t=(u*l+y-x)/(difmn);break;}}
		else if (quti<=0.10)
			for(t=1;t<=2000000000;t++)
			{if((t*(difmn)+x-y)%l==0) break;}
		else if (quti<1.0&&quti>0.10)
			for(int ut=1;ut<=2000000000;ut++)
			{if((l*ut+y-x)%(difmn-l)==0){t=(l*ut+y-x)/(difmn-l);break;}}
		else if (quti>1.0&&quti<10)
			for(int tu=1;tu<=2000000000;tu++)
			{if((l*tu+x-y)%(l-difmn)==0){t=(l*tu+x-y)/(l-difmn);break;}}
		else if (l==difmn) printf("Impossible\n");
	printf("%d\n",t);
	}
    }else printf("Impossible\n");
}

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