| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:莫名其妙就过了,我都不知道为什么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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator