题目: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. iOS应用的执行原理

    本文转自:http://www.cnblogs.com/oc-bowen/p/6061261.html http://www.cnblogs.com/oc-bowen/p/6061178.html 一 ...

  2. zookeeper curator CRUD

    目录 Curator客户端的基本操作 写在前面 1.1.1. Curator客户端的依赖包 1.1.2. Curator 创建会话 1.1.3. CRUD 之 Create 创建节点 1.1.4. C ...

  3. 区分Web前端和后端(转载)

    转载自:http://blog.csdn.net/rosetta/article/details/53871766 前言   做C开发将近六年,基本上没有接触过web相关的东西,原来听别人说web相关 ...

  4. Qt插件开发入门(两种方法:High-Level API接口,Low-Level API接口)

    Qt中为我们提供了两种开发插件的方式.一种是使用High-Level API接口,一种是使用Low-Level API接口.所谓High-Level API 是指通过继承Qt为我们提供的特定的插件基类 ...

  5. go语言之并发编程 channel(1)

    单向channel: 单向通道可分为发送通道和接收通道.但是无论哪一种单向通道,都不应该出现在变量的声明中,假如初始化了这样一个变量 var uselessChan chan <- int =m ...

  6. sublime运行Python

    1.首先安装Python 我这里安装的是Python的3.7版本. 这里有两种安装方式 第一种: 默认路径安装,勾选添加到path复选框(这种情况,sublime可以直接运行Python了) 第二种: ...

  7. maven编译问题-maven项目运行时找不到文件,解决方案之一

    问题描述:以上信息是tomcat在启动项目的时候报的错误信息,发现没有找到配置文件,实际上配置文件在项目中是存在的,但是,在编译过程中,配置文件没有能加载到编译后的项目中.就造成了,找不到这些怕配置文 ...

  8. Swift——(四)Swift中"#"的妙用

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/twlkyao/article/details/31350841     在Swift中," ...

  9. JavaScript中的this用法

    最近看了许多JavaScript源代码,发现this经常出现,于是对this这个非常特殊的关键词标识符进行总结. 题外话: 1.当函数被调用时,一个activation record[过程活动记录 - ...

  10. 11.23 Eclipse

    一.Eclipse Workspace File-->Switch Workspace 编译环境:Window -- Preferences – Java - Compiler 运行环境:Win ...