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 |
HELP~~ 有什么特别的数据吗? sample 的结果是对的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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator