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

HELP~~ 有什么特别的数据吗? sample 的结果是对的

Posted by minidick at 2004-04-21 21:47:56 on Problem 1079
main()
{
	int g,l,i,j,k;
	double t,dt,d;
	while (scanf("%d%d",&g,&l)==2) {
		if (g>l) {i=g;j=l;}
		else {i=l;j=g;}
		while (1) {
			k=j;
			if (j=i%j) i=k;
			else break;
		}
		g/=k;l/=k;
		t=(double)g/l;
		dt=5000;
		for (j=1;j<l;j++) {
			i=t*j;
			d=t-(double)i/j;
			if (d>0.5/j) {
				i++;
				d=1.0/j-d;
			}
			if (d<dt) {
				dt=d;
				printf("%d/%d\n",i,j);
			}
		}
		printf("%d/%d\n\n",g,l);
	}
}

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