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 hongye at 2006-01-01 19:09:35
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
 long x,y,m,n,L,i;
 cin>>x>>y>>m>>n>>L;
 if(m==n)
	 cout<<"Impossible"<<endl;
 else
 {
 if(L%(m-n)==0)
 {
  if((x-y)%(m-n)==0)
   cout<<(L-abs(x-y))/abs(m-n)<<endl;
  else
   cout<<"Impossible"<<endl;
 }
 else
  {
   if((x-y)%(m-n)==0)
     cout<<L-abs(x-y)/abs(m-n)<<endl;
   else
     {
       for(i=1;i<abs(m-n);i++)
        {
          if((L%abs(m-n)*i)%abs(m-n)==abs(x-y)%abs(m-n))
         {
            cout<<i<<endl;
             break;
          }
        }
       if(i>=abs(m-n))
         cout<<"Impossible"<<endl;
      } 
    }
 }
 return 0;
 }  

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