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

错了,是把y从32767开始就WA!

Posted by y05yxg at 2006-10-20 21:51:20 on Problem 3039
In Reply To:瞧啊!!若把y从1开始就WA! Posted by:y05yxg at 2006-10-20 21:49:30
> #include<iomanip.h>
> #include<math.h>
> int main()
> {
> 	double n,d,an,ad,t,m,c,x,y,max;
> 	while(cin>>n>>d)
> 	{
> 		m=n/d;
> 		y=1;
> 		max=32767;
> 		while(y<=32767)
> 		{
> 			x=floor(y*m)-1;
> 			if(x<=0)x=1;
> 			while(1)
> 			{
> 				t=x/y;			
> 				c=fabs(t-m);
> 				if(c<max)
> 				{
> 					if(c!=0)
> 					{
> 						an=x;
> 						ad=y;
> 						max=c;
> 					}
> 				}
> 				else if(t>m)break;
> 				x++;
> 			}
> 			y++;
> 		}
> 		cout<<an<<' '<<ad<<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