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 |
错了,是把y从32767开始就WA!In Reply To:瞧啊!!若把y从1开始就WA! Posted by:y05yxg at 2006-10-20 21:49:30 > #include<iomanip.h> > #include<math.h> > int main() > { > double n,d,an,ad,t,m,c,x,y,max; > while(cin>>n>>d) > { > m=n/d; > y=1; > max=32767; > while(y<=32767) > { > x=floor(y*m)-1; > if(x<=0)x=1; > while(1) > { > t=x/y; > c=fabs(t-m); > if(c<max) > { > if(c!=0) > { > an=x; > ad=y; > max=c; > } > } > else if(t>m)break; > x++; > } > y++; > } > cout<<an<<' '<<ad<<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