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 |
请教一下我的想法很简单,从起点方面看:有青蛙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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator