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 WinterWingC at 2011-09-13 22:01:50 on Problem 1079
In Reply To:程序就像妹子的迷你裙 越短越好……看我的性感423Byte程序 Posted by:Sayakiss at 2010-07-01 13:14:15
#include <iostream>
#include <math.h>
using namespace std;

int i, a, b;
long double j, ans;
int main()
{
	while (cin >> a >> b)
	{
		ans=1E9;
		for (i=1; i<=b; i++)
		{
			j=(int)((double)i*a/b+0.5);
			if (fabs((double)(j)/i-(double)a/b)<ans)
			{
				ans=fabs((double)(j)/i-(double)a/b);
				cout << j << '/' << i << endl;
			}
		}
		cout << 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