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:怎么用C++能AC,用G++却过不了!In Reply To:怎么用C++能AC,用G++却过不了! Posted by:paul08colin at 2011-01-24 16:41:10 me too who can help me ! code here: #include<stdio.h> #include<string.h> #include <math.h> #define Exp 1E-7 #define pi (4 * atan(1.0)) double s; double f(double r) { double l = (s -pi*r*r)/(pi*r); double ans=(1.0/3)*pi*r*r*sqrt(l*l-r*r); return ans; } void third_seperate_search(double s) { double l=0; double r=sqrt(s*0.5/pi); // double r=2; //printf("r=%lf\n",r); double x1,x2; while(r-l>Exp){ x1=l+(r-l)/3; x2=r-(r-l)/3; if(f(x1)>f(x2))r=x2; else l=x1; } double L=(s -pi*r*r)/(pi*r); double h=sqrt(L*L-r*r); printf("%.2lf\n",f(r)); printf("%.2lf\n",h); printf("%.2lf\n",r); // printf("%.2lf",r); } int main() { // freopen("aaa.txt","r",stdin); // freopen("aaaa.txt","w",stdout); while (scanf("%lf", &s) != EOF) { third_seperate_search(s); // for(double i=1;i<10;i+=0.1) // printf("%lf %lf\n",i,f(i)); }//end of cas } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator