题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define db double
using namespace std;
const db eps=1e-;
int T;db a,b,l,r;
db f(db x){return sqrt((-x*x/a)*b);}
db cal(db l,db r){return (f(l)+*f((l+r)/)+f(r))*(r-l)/;}
db simp(db l,db r,db eps,db ret)
{
db mid=(l+r)/,vl=cal(l,mid),vr=cal(mid,r);
if(fabs(vl+vr-ret)<=*eps)return vl+vr+(vl+vr-ret)/;//not ret+()/15
return simp(l,mid,eps/,vl)+simp(mid,r,eps/,vr);
}
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
a*=a;b*=b;
printf("%.3lf\n",simp(l,r,eps,cal(l,r))*);
}
return ;
}

hdu 1724 Ellipse——辛普森积分的更多相关文章

  1. HDU 1724 Ellipse [辛普森积分]

    Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  2. hdu 1724 Ellipse simpson积分

    /* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...

  3. HDU 1724 Ellipse ——Simpson积分

    [题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...

  4. HDU 1724 Ellipse (自适应辛普森积分)

    题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...

  5. hdu 1724 Ellipse —— 自适应辛普森积分

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...

  6. HDU 1724 Ellipse 【自适应Simpson积分】

    Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  7. HDU 1724 Ellipse(数值积分の辛普森公式)

    Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...

  8. HDU 1724 Ellipse 自适应simpson积分

    simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...

  9. hdu 1724 : Ellipse 【Simpson积分】

    题目链接 题意:给出椭圆方程中的a和b,再给出l.r,求l到r的积分的二倍. 输出时要求精度控制为保留到小数点后3位,如下代码中,eps设为1e-9 1e-8时均TLE,1e-4可以AC,1e-3会W ...

随机推荐

  1. python sort与sorted使用笔记

    Python list内置sort()方法用来排序,也可以用python内置的全局sorted()方法来对可迭代的序列排序生成新的序列 一,最简单的排序 1.使用sort排序 my_list = [3 ...

  2. IOS-Quartz2D

    一.画基本图形 // // BWView.m // IOS_0221_Quartz2D画矩形 // // Created by ma c on 16/2/21. // Copyright © 2016 ...

  3. Post with HttpClient4

    转载:http://www.cnblogs.com/luxiaoxun/p/6165237.html 作者:阿凡卢 出处:http://www.cnblogs.com/luxiaoxun/ HttpC ...

  4. laravel中设置表单的方式,以及获取表单的提交的数据

  5. Jqeury ajax 调用C#的后台程序

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="JQueryTest.aspx. ...

  6. 淘宝TDDL深入浅出

    前言 在开始讲解淘宝的 TDDL(Taobao Distribute Data Layer) 技术之前,请允许笔者先吐槽一番.首先要开喷的是淘宝的社区支持做的无比的烂, TaoCode 开源社区上面, ...

  7. ios8 - CoreLocation定位服务的变化

    在iOS8开发中,发现一个CoreLocation的使用问题,执行操作之后,不会调用到定位之后的delegate方法中. 根据文档,需要在使用CoreLocation前调用方法: [locationm ...

  8. New Concept English three (24)

    33 72 We often read in novels how a seemingly respectable person or family has some terrible secret ...

  9. 如何将dom4j的jar包放到java项目中

    ---恢复内容开始--- 如果你建的是java project项目的话,那就通过Myeclispe中的右键你的项目名称,选择build path ->config build path... 然 ...

  10. js的事件循环机制和任务队列

    上篇讲异步的时候,提到了同步队列和异步队列的说法,其实只是一种形象的称呼,分别代表主线程中的任务和任务队列中的任务,那么此篇我们就来详细探讨这两者. 一.来张图感受一下 如果看完觉得一脸懵逼,请继续往 ...