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

大家帮我看看我的程序阿 wronganswer!

Posted by strideryu at 2009-02-22 16:38:40 on Problem 1061
using namespace std;
int main()
{
unsigned int x,y,m,n,l,t;
cin>>x>>y>>m>>n>>l;
if(m==n)cout<<"Impossible"<<endl;
else 
   {
   unsigned int r1,r2,d_r;
   t=1;
   r1=x+m*t;
   r2=y+n*t;
   r1>r2?(d_r=(r1-r2)):(d_r=(r2-r1));
   for(;d_r%l!=0;r1+=m,r2+=n,t++){
      r1>r2?(d_r=(r1-r2)):(d_r=(r2-r1));
      if((r1%l==x&&r2%l==y)){
      cout<<"Impossible"<<endl;
      m=0;
      break;}
      }       
   if(m!=0)cout<<t-1;
   }
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