标签:important cas return pos ott name mit contain argc
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1868 Accepted Submission(s): 792
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; const double eps=1e-10; double a,b,l,r; inline double F(double x){ return sqrt((a*a-x*x)/(a*a))*b; } inline double cal(double l,double r){ return (F(l)+F(r)+4*F((l+r)/2))*(r-l)/6; } double Simpson(double l,double r,double now){ double mid=(l+r)/2,p=cal(l,mid),q=cal(mid,r); if(abs(now-p-q)<eps) return now; else return Simpson(l,mid,p)+Simpson(mid,r,q); } int main(int argc, const char * argv[]) { int T;scanf("%d",&T); while(T--){ scanf("%lf%lf%lf%lf",&a,&b,&l,&r); l=max(l,-a);r=min(r,a); printf("%.3f\n",2*Simpson(l,r,cal(l,r))); } return 0; }
标签:important cas return pos ott name mit contain argc
原文地址:http://www.cnblogs.com/candy99/p/6360043.html