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:莫名其妙就过了,我都不知道为什么

Posted by 110405221 at 2012-11-03 17:48:13 on Problem 1061
In Reply To:莫名其妙就过了,我都不知道为什么 Posted by:TSERROF at 2012-09-03 20:49:20
> #include <cstdio>
> long long X,Y;
> void GCD(long long A,long long B,long long &gcd)
> {
> 	if(B){GCD(B,A%B,gcd);long long t=X;X=Y;Y=t-(A/B)*Y;}
> 	else {gcd=A;X=1,Y=0;}
> }
> int main()
> {
> 	long long x,y,m,n,B;
> 	while(scanf("%lld%lld%lld%lld%lld",&x,&y,&m,&n,&B)!=EOF)
> 	{
> 		long long A=n-m,C=x-y,gcd;
> 		GCD(A,B,gcd);
> 		if(C%gcd) printf("Impossible\n");
> 		else
> 		{
> 			X*=C/gcd;
> 			Y*=C/gcd;
> 			if(X>0)X%=B;
> 			else X=X%B+B;
> 			printf("%lld\n",X);
> 		}
> 	}
> 	return 0;
> }

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