Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁能告诉我这个代码哪儿错了,我快看疯了......青蛙的约会问题 1061

Posted by fkeps at 2009-11-24 19:12:29
谁能告诉我这个代码哪儿错了 青蛙的约会问题 1061
顺便最好给几组测试数据!!!!!!!!!!!!!!!!!!

#include<iostream>
using namespace std;
int main()
{
    unsigned long x,y,m,n;
    long xy,mn,L,i;
    cin>>x>>y>>m>>n>>L;
    xy=x-y;
    mn=m-n;
    if(mn<0)
    {
            mn*=-1;
            xy*=-1;
    }
    if(L==0)
    {
            cout<<"Imposible"<<endl;
            system("pause");
            return 0;
    }
    mn%=L;
    if(xy%L==0)
    {
        cout<<0<<endl;
    }
    else if(mn==0 & xy%L!=0)
        cout<<"Imposible"<<endl;
    else
    {
         if(xy>0)i=1;
         else i=0;
         for(;i<=mn;i++)
                 if((L*i-xy)%mn==0) 
                       break;
         cout<<(i*L-xy)/mn<<endl;
     }
     system("pause");
     return 0;
}
谁能告诉我这个代码哪儿错了 青蛙的约会问题 1061
顺便最好给几组测试数据!!!!!!!!!!!!!!!!!!


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator