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 |
程序就像妹子的迷你裙 越短越好……看我的性感423Byte程序In Reply To:很easy就解决了蛮。。放AC代码 Posted by:yzhw at 2009-06-19 21:15:53 # include<stdio.h> # include<stdlib.h> int i,p,q,pt,a,b; int main() { while (scanf("%d%d",&a,&b)!=-1) { p=1;q=0; for (i=1;i<=b;i++) { pt=(double)(i*a)/(double)b+0.5; if (q*abs(a*i-b*pt)<i*abs(a*q-b*p)) {p=pt;q=i;printf("%d/%d\n",p,q);} if (a*q==b*p) break; } printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator