| ||||||||||
| 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 | |||||||||
哪里错了,为何wa#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
long long x,y,e;
void gcd(long long a,long long b,long long c)
{
if(a==0)
{x=0,y=c/b,e=b;return;}
gcd(b%a,a,c);
long long t=y;
y=x,x=t-(b/a)*x;
}
int main()
{
long long a,b,m,n,l;
scanf("%I64d%I64d%I64d%I64d%I64d",&a,&b,&m,&n,&l);
if(m<n)swap(a,b),swap(m,n);
gcd(m-n,l,b-a);
if((b-a)%e!=0)printf("Impossible\n");
else
{
if(e!=0)
{
long long d=(m-n)*l/e;
if(x<1){x+=(-x+1)/(d/(m-n))*d/(m-n);if(x<1)x+=d/(m-n);}
else x-=(x-1)/(d/(m-n))*(d/(m-n));
}
printf("%I64d\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