| ||||||||||
| 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 main()
{
unsigned long x,y,m,n,l,t=0;
long r;
cin>>x>>y>>m>>n>>l;r=y-x;
while(1)
{
if(x==y)
{
cout<<"Impossible";
break;
}
t++;
x+=m;y+=n;
if(x>l)
x%=l;
if(y>l)
y%=l;
if((r<0)&&((r==(y-x)||(r==(y-l-x)))))
{
cout<<"Impossible";
break;
}
if((r>0)&&((r==(y-x)||(r==(l-x+y))))) //这个地方有什么问题?????
{
cout<<"Impossible";
break;
}
if(x==y)
{
cout<<t;
break;
}
}
cout<<endl;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator