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

函数都给出来了,可以用辛普森积分;

一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 eps = 1e-5 即可;

这次用了比较标准的写法^_^

代码如下:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef double db;
db const eps=1e-;
db a,b,l,r;
db f(db x){return b*sqrt(-(x*x)/(a*a));}
db simp(db l,db r){return (r-l)/*(f(l)+*f((l+r)/)+f(r));}
db asr(db l,db r,db eps,db lst)
{
db mid=(l+r)/;
db ls=simp(l,mid),rs=simp(mid,r);
if(fabs(ls+rs-lst)<=*eps)return (ls+rs+(ls+rs-lst)/);//
return asr(l,mid,eps/,ls)+asr(mid,r,eps/,rs);
}
db asme(db l,db r,db eps){return asr(l,r,eps,simp(l,r));}
int main()
{
int T; scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
printf("%.3f\n",asme(l,r,eps)*);
}
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 自适应辛普森模板

    OJ 题解传送门 //Achen #include<algorithm> #include<iostream> #include<cstring> #include ...

  3. HDU 1724 Ellipse 自适应simpson积分

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

  4. hdu 1724 : Ellipse 【Simpson积分】

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

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

    题目链接 题意 给出一个椭圆,问一个[l, r] 区间(蓝色区域)的面积是多少. 思路 自适应辛普森积分 具体一些分析如上. 很方便,套上公式就可以用了. 注意 eps 的取值影响了跑的时间,因为决定 ...

  6. hdu 1724 Ellipse simpson积分

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

  7. 【自适应辛普森积分】hdu1724 Ellipse

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

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

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

  9. HDU 1724 Ellipse

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

随机推荐

  1. Card Collector

    In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...

  2. element-ui table 点击分页table滚动到顶部

    在做项目中,碰到一个问题,table加了固定头,内容可滚动,当滚到table底边时,点击分页后还在底边 解决方法:设置table的 ref='multipleTable' //切换分页的方法加上下面这 ...

  3. [IOI2018]组合动作

    IOI2018 组合动作 UOJ 首先显然可以两次试出首字母 考虑增量构造 假设首字母为A,且已经试出前i个字母得到的串s 我们考虑press这样一个串s+BB+s+BX+s+BY+s+XA 首先这个 ...

  4. Django之stark组件的使用和总结

    Stark组件的使用 组件的字段 list_display=[] 需要显示的字段 list_display_links=[] #需要链接编辑字段 Stark_Model_Form=[] #设置Mode ...

  5. Linux安装virtualenvwrapper详细步骤

    1.[root@localhost ~]# pip install virtualenvwrapper 2.[root@localhost ~]# pip list [root@localhost ~ ...

  6. G20峰会将会给数字货币带来哪些影响?

    G20峰会对于全球经济有着举足轻重的影响,其成员人口占全球的2/3,国土面积占全球的60%,国内生产总值占全球的90%,贸易额占全球的75%……作为国际经济合作的主要平台,G20在引领和推动国际经济合 ...

  7. IE11 for Windows 7 Enterprise With SP1 故障

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jaminwm/article/details/29592027 这个故障非常诡异,卸载IE11也没实 ...

  8. ABAP 内表

    定义内表 1. 先声明表结构, 再根据表结构定义内表.   TYPES: BEGIN OF w_itab, a(10), b(10), END OF w_itab. DATA: itab1 type ...

  9. Call method 的使用

    SAP学习日志---Call method 的使用 以及常见错误 转载▼   可以通过以下方法 call method 1. 进入全局类中 找到方法,拖到程序中 2. 使用pattern 中的 AAB ...

  10. 第11条:用zip函数同时遍历两个迭代器

    核心知识点: (1)内置的zip函数可以平行地遍历多个迭代器. (2)python3中地zip相当于生成器,会在遍历过程中逐次产生元祖.而python2中地zip则是直接把这些元祖完全生成好,并一次性 ...