| ||||||||||
| 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 | |||||||||
1061问题求救,不知道wrong在何处。第一次提交可能规则不懂,望大牛们指教。。。#include <iostream.h>
long SkipTimes(long x,long y,long m,long n,long L);
void main()
{
long x,y,m,n,L;
cin>>x>>y>>m>>n>>L;
if(x==y)
{
cout<<"X != Y"<<endl;
return;
}
if(m<0||n<0)
{
cout<<"M or N < 0"<<endl;
return;
}
if(L<0)
{
cout<<"L < 0"<<endl;
}
long T = SkipTimes(x,y,m,n,L);
if(T == -1)
cout<<"Impossible"<<endl;
else
cout<<T<<endl;
}
long SkipTimes(long x,long y,long m,long n,long L)
{
for(long i=1;;i++)
{
if( ((x+m*i)%L)==((y+n*i)%L) )
return i;
else if(i > 4*L*L)
return -1;
else
continue;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator