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

请教一下

Posted by onikage at 2009-02-09 15:42:54 on Problem 1061
我的想法很简单,从起点方面看:有青蛙A的起点比青蛙B的起点大时,也有小的时候
从跳的元度来看,有青蛙A比青蛙B远,也有青蛙A比青蛙跳的近代时候,一共就是4种情况
我的代码如下,但是系统却报错,或者超出输出限制,如果方便的话,请指点一下
#include <iostream>
using namespace std;
int main()
{long x,y,m,n,l,p,q,r;
 cin>>x>>y>>m>>n>>l;
 while(x>y)
  {
  p=x-y;
  if(m==n)
    {cout<< "Impossible";break;
    }
   if(m>n)
   {q=m-n;
   }else q=n-m;
   if(p%q==0)
    {r=p/q;cout<<l-r;
    }
    else cout<<"Impossible";
  }
 while(x<y)
  {p=y-x;
   if(m==n)
    {cout<< "Impossible";break;
    }
   if(n>m)
   {q=n-m;
   }else q=m-n;
   if(p%q==0)
    {r=p/q;cout<<l-r;
    }else cout<<"Impossible";
  }
}

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