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 |
Re:为什么会WA!In Reply To:为什么会WA! Posted by:wanpi0user at 2005-05-16 22:48:03 > 请指点! > 已通过测试数据。本程序未对分子分母化简,因为这没必要! > //****************************************************************** > //********* ********* > //********* ********* > //wanpi0user > // > //****************************************************************** > #include<iostream> > #include<iomanip> > #include<algorithm> > #include<fstream> > #include<sstream> > #include<cstdlib> > #include<cstdio> > #include<cmath> > #include<string> > using namespace std; > int main(){ > int d,L,p,i; > double eps=1.0; > double A,D,P; > cin>>A>>L; > for(i=1;i<L;i++){ > D=i; > P=floor(D*A+0.5); > //if((P<L)&&(abs(P/D-A)<eps)){eps=abs(P/D-A);d=i;p=floor(D*A+0.5);} > if(P<L&&(fabs(P/D-A)<eps)){ > eps=fabs(P/D-A); > d=i;p=floor(D*A+0.5);} > //cout<<(P/D-A)<<'\t'<<setw(10)<<eps<<'\t'<<A<<endl; > } > cout<<p<<" "<<d<<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