| ||||||||||
| 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 | |||||||||
那位高手给看一下,在下面编译对了,可一旦上去就错,狂郁闷啊!#include <iostream>
using namespace std;
int fabs(unsigned long a,unsigned long b)
{
if(a>b) return a-b;
else return b-a;
}
int main()
{
unsigned long x,y,m,n,l,i,j,jud=1,a=0,k,t1,t2,iy;
cin>>x>>y>>m>>n>>l;
while(jud!=0)
{
if(fabs(x,y)%fabs(m,n)==0||fabs(m,n)%fabs(x,y)==0) //约会成功
{
iy=y;
for(i=x;i<=l;i+=m)
{
iy+=n;
j=(i-x)/m;
if((x+j*m)==(y+j*n))
{
cout<<(j+a)<<endl;
jud=0;
}
}
a+=(l-x)/m+1;
t1=i;
t2=iy;
for(k=0;t2<=l;++k)
{
t1=t1+k*m;
t2=t2+k*n;
}
x=t1;y=t2;
for(i=1;x>l;++i)
{
x=t1-l*i;
}
for(i=1;y>l;++i)
{
y=t2-l*i;
}
if(x==5) x=0;
if(y==5) y=0;
a+=k;
}
else //约会失败
{
cout<<"Impossible"<<endl;
jud=0;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator