Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:怎么用C++能AC,用G++却过不了!

Posted by JustForU at 2011-03-08 20:38:59 on Problem 3737
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator