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

老师WA关你什么事,你不WA不就行了?^_^

Posted by liulibo133 at 2007-12-05 00:08:53 on Problem 1061
In Reply To:大家看看我的代码哪里错了,老师WA,急啊,高手帮忙~~~ Posted by:minstar at 2007-12-04 22:02:45
> #include<iostream.h> 
> 
> int simplify(int s,int t)	//寻找 s 和 t 的最大公约数,并返回最大公约数
> {
> 	int a, b, r;
> 
> 	if ( t > s)
> 	{ 
> 		a = t ; b = s ;
> 	}
> 	
>     else
> 	{ 
> 		a = s ; b = t ; 
> 	}
> 
> 	r = b ;	
> 	
> 	while ( r != 0 )
> 	{ 
> 		r = a % b ;		
> 		a = b ;			
> 		b = r ;
> 	}
> 	
> 	return a;
> }
> 
> int result(int a,int b,int c)
> {
> 	int r;
> 
> 	r = simplify(a,c);
> 
> 	if(r!=1 && b%r!=0)
> 		return 0;
> 	
> 	else 
> 		return 1;
> }
> 
> 
> int main()
> {
> 	unsigned long A,B;
> 	unsigned long x,y,m,n,l;
> 	cin>>x>>y>>m>>n>>l;//(x!=y)
> 	if(x==y)
> 		return 0;
> 	if(x>=2000000000)
> 		return 0;
> 	if(y>=2000000000)
> 		return 0;
> 	if(m<=0||m>=2000000000)
> 		return 0;
> 	if(n<=0||n>=2000000000)
> 		return 0;
> 	if(l<=0||l>=2100000000)
> 		return 0;
> 	int a = m-n;
> 	if(a==0)
> 	{	cout<<"impossible"<<endl;  }
> 	else
> 	{
> 		if(a>0)
> 		{
> 			A = x;
> 			B = y;
> 			a = a;
> 		}
> 		else
> 		{
> 			A = y;
> 			B = x;
> 			a = -a;							// 12 10 3 7 22
> 		}
> 
> 		if(result(a,(A-B),l)==0)  //确认是否可以到达
> 			cout<<"impossible"<<endl;	
> 
> 		else
> 		{
> 			for(int i=0;;i++)
> 			{
> 				A += a;
> 				if((A-B)%l==0)
> 					break;
> 			}
> 			cout<<i+1<<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