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 DKey at 2007-05-29 12:52:11 on Problem 1061
#include "stdio.h"
#include "math.h"
#include "iostream.h"

int main(int argc, char* argv[])
{
	long x,y,m,n,L;
	cin>>x>>y>>m>>n>>L;
	if(x==y||x<0||y<0||x>= 2000000000||y>= 2000000000||m>= 2000000000||n>= 2000000000||L>= 2100000000||m<=0||n<=0||L<=0)
	{return 0;} 
	else
	{	
		long a,b,c;
		a=L;b=n-m;c=x-y;
		if(b==0){cout<<"Impossible"<<endl;}
		else{
		long A[10000]={0};
		long x=a,y=abs(b),d,temp;
		long u0,u1,u,v0,v1,v;
		int i=0,j=2;
		while(y!=0)
		{
			temp=y;
			A[i]=x/y;
			y=x%y;	
			x=temp;
			i++;
		}
		d=temp;
		u0=1;u1=A[0];v0=0;v1=1;u=u0+A[1]*u1;v=v0+v1*A[1];
		while(j<i)
		{
									
			u0=u1;
			u1=u;
			u=u0+A[j]*u1;
			v0=v1;
			v1=v;
			v=v0+v1*A[j];
			j++;
		}
		if(c%d!=0) cout<<"Impossible"<<endl;
		else
		{
			int e=(a*v>abs(b)*u)?1:(-1);
			int f=(b>0)?1:(-1);
			long x0=e*c*v/d,y0=-e*f*c*u/d,y,k=abs(y0)*d/a;
			y=(y0>0)?(y0%(a/d)):((k+1)*a/d+y0);
			cout<<y<<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