| ||||||||||
| 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 | |||||||||
1000组数据全只有851我是73,其他的全过了,怎么还是WA?// oj.cpp : 定义控制台应用程序的入口点。
//
#include <iostream>
using namespace std;
int main()
{
int x,y,m,n,L;
int sm,sn,jn,ok,im;
//while(1) {
cout<<" Please input x y m n L"<<endl;
cin >> x >> y>>m>>n>>L;
//while (x==y||x>2000000000||x<=0||y>2000000000||y<=0||m<=0||m>=2000000000||n<=0||n>=2000000000||L<=0||L>=2100000000)
//{
// cout<<" The data is incorrect, please input x y m n L"<<endl;
// cin >> x >> y>>m>>n>>L;
//}
ok=0;
jn=0;
x=x%L;
y=y%L;
//if(x==y){
// ok=1;
//}
sm=x;
sn=y;
im=0;
if(sm!=sn&&m==n&&ok==0){
im=1;
}
while (ok==0&&im==0)
{
jn++;
sm=(sm+m)%L;
sn=(sn+n)%L;
if(sm!=sn&&sm==x&&sn==y) {
im=1;
break;
}
//cout<<"sm = "<<sm<<" ; sn = "<<sn<<endl;
if(sm==sn) {
ok=1;
} else {
ok=0;
}
}
if(im==0&&ok==1) {
cout<<jn<<endl;
} else
{
cout<<"Impossible"<<endl;
}
//}
//cin.get();
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator