Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
的确越短越好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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator