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 niubingwei at 2009-05-26 11:21:12
#include <iostream>
using namespace std;
int fabs(unsigned long a,unsigned long b)
{
	if(a>b) return a-b;
	else return b-a;
}
int main()
{
	unsigned long x,y,m,n,l,i,j,jud=1,a=0,k,t1,t2,iy;
	cin>>x>>y>>m>>n>>l;
	while(jud!=0)		
	{
		if(fabs(x,y)%fabs(m,n)==0||fabs(m,n)%fabs(x,y)==0)		//约会成功
		{ 
			iy=y;
			for(i=x;i<=l;i+=m)		
			{
				iy+=n;
				j=(i-x)/m;	
				if((x+j*m)==(y+j*n))
				{
					cout<<(j+a)<<endl;
					jud=0;	
				}
			}
			a+=(l-x)/m+1;	
			t1=i;
			t2=iy;
			for(k=0;t2<=l;++k)	
			{
				t1=t1+k*m;
				t2=t2+k*n;
			}
			x=t1;y=t2;
			for(i=1;x>l;++i)
			{ 
				x=t1-l*i;
			}
			for(i=1;y>l;++i)
			{
				y=t2-l*i;
			}
			if(x==5) x=0;
			if(y==5) y=0;
			a+=k;
		}
		else			//约会失败
		{
			cout<<"Impossible"<<endl;
			jud=0;

		}
	}
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