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 bright128 at 2008-02-27 21:11:32 on Problem 1061
#include<iostream>
using namespace std;
int main()
{
	int a=0,x,y,m,n,l,xx,yy;

	cin>>x>>y>>m>>n>>l;
    while(x!=y){
		a++;
		xx=x;
		yy=y;
		x=x+m;
		y=y+n;
		while(x>l || y>l){
			if(x>l){
				x=x-l;
			}
		    if(y>l){
			    y=y-l;
			}
	
		}
		if(x==xx && y==yy){
			cout<<"impossible"<<endl;
			return 0;
			break;
		}
	}
	cout<<a<<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