OJ

题解传送门

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
int T;
double a,b,l,r;
using namespace std; double f(double x) {
return b*sqrt(1.0-(x*x)/(a*a));
} double sim(double x,double y) {
double mid=((x+y)/2.0);
return (y-x)/6.0*(f(x)+4.0*f(mid)+f(y));
} double calc(double l,double r,double eps) {
double mid=((l+r)/2.0);
double tp=sim(l,mid)+sim(mid,r),tpp=sim(l,r);
if(tp-tpp<=eps*15.0) return tp+(tp-tpp)/15.0;
else return calc(l,mid,eps/2.0)+calc(mid,r,eps/2.0);
} int main() {
scanf("%d",&T);
while(T--) {
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
printf("%.3lf\n",calc(l,r,1e-)*2.0);
}
return ;
}

这里还有一道自适应辛普森模板

传送门

HDU - 1724 Ellipse 自适应辛普森模板的更多相关文章

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

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

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

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

  3. HDU 1724 Ellipse 自适应simpson积分

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

  4. hdu 1724 Ellipse simpson积分

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

  5. HDU 1724 Ellipse

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

  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——辛普森积分

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...

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

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

随机推荐

  1. v-bind:class

    <!DOCTYPE html> <html lang="zh"> <head> <title></title> < ...

  2. CAS(客户端)程序获取安全证书

    以下是获取安全证书的一种方法,通过以下程序获取安全证书: import java.io.BufferedReader; import java.io.File; import java.io.File ...

  3. pymysql 使用

    适用环境 python版本 >=2.6或3.3 mysql版本>=4.1 安装 可以使用pip安装也可以手动下载安装. 使用pip安装,在命令行执行如下命令: 1 pip install  ...

  4. windows API 第八篇 _tcsicmp _stricmp _wcsicmp _mbsicmp

    这些函数都是比较字符串小写的,忽略大写,出入的字符串都将按照小写比较Perform a lowercase comparison of strings. 函数原型: int _stricmp( con ...

  5. pg_hba.conf配置文件

    实例级别的权限由pg_hba.conf来控制,例如 : # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix doma ...

  6. Python 编码转换与中文处理

    python 中的 unicode是让人很困惑.比较难以理解的问题. 这篇文章 写的比较好,utf-8是 unicode的一种实现方式,unicode.gbk.gb2312是编码字符集. py文件中的 ...

  7. Django项目:CMDB(服务器硬件资产自动采集系统)--03--03CMDB信息安全API接口交互认证

    #settings.py """ Django settings for AutoCmdb project. Generated by 'django-admin sta ...

  8. js节点

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. jeecms 修改后台访问路径

       版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_30553235/article/details/74971414 我使用的是jeecms ...

  10. PAT甲级——A1038 Recover the Smallest Number

    Given a collection of number segments, you are supposed to recover the smallest number from them. Fo ...