hdu 1724 Ellipse —— 自适应辛普森积分
题目: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 —— 自适应辛普森积分的更多相关文章
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
- HDU - 1724 Ellipse 自适应辛普森模板
OJ 题解传送门 //Achen #include<algorithm> #include<iostream> #include<cstring> #include ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
- hdu 1724 : Ellipse 【Simpson积分】
题目链接 题意:给出椭圆方程中的a和b,再给出l.r,求l到r的积分的二倍. 输出时要求精度控制为保留到小数点后3位,如下代码中,eps设为1e-9 1e-8时均TLE,1e-4可以AC,1e-3会W ...
- HDU 1724:Ellipse(自适应辛普森积分)
题目链接 题意 给出一个椭圆,问一个[l, r] 区间(蓝色区域)的面积是多少. 思路 自适应辛普森积分 具体一些分析如上. 很方便,套上公式就可以用了. 注意 eps 的取值影响了跑的时间,因为决定 ...
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
- 【自适应辛普森积分】hdu1724 Ellipse
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
随机推荐
- javax.servlet.ServletException: Could not resolve view with name‘ XXXX’in servlet with name 'spring'的解决方案-----SKY
出现的异常如下: javax.servlet.ServletException: Could not resolve view with name '{"msg":"成功 ...
- 存储过程 & 触发器
触发器主要是通过事件进行触发而被执行的,而存储过程可以通过存储过程名字而被直接调用.当对某一表进行诸如UPDATE. INSERT. DELETE 这些操作时, 就会自动执行触发器所定义的SQL 语句 ...
- go语言之面向对象一
在Go语言中, 你可以给任意类型(包括内置类型,但不包括指针类型)添加相应的办法.示例如下: type Integer int func (a Integer) Less(b Integer) boo ...
- windows下安装PyQt4
第一步:确认自己电脑上的Python版本.然后下载对应的.whl文件下载 第二步:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4上下载对应版本版本的 ...
- LeetCode:字母异位词分组【16】
LeetCode:字母异位词分组[16] 题目描述 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 示例: 输入: ["eat", &quo ...
- React Native 列表的总结
React Native 列表的总结 FlatList和SectionList都是React Native中高性能的列表组件.这些新的列表组件在性能方面都有了极大的提升, 其中最主要的一个是无论列表有 ...
- MySQL5.7.9(GA)的安装
1.解压ZIP文件到安装目录: 2.进入到bin目录,试运行mysqld --console,查看可能的出错信息,安装相应的辅助软件,如.net V4.0等: 3.编辑my.ini文件,关键内容如下: ...
- EntityFramework 学习 一 Lazy Loading 1
延迟加载:延迟加载相关的数据 using (var ctx = new SchoolDBEntities()) { //Loading students only IList<Student&g ...
- 句柄与MFC对象关系和相互获取
Windows对象是以句柄来标识的,对应的MFC类就是这些句柄的C++包装.内存中的Windows对象一定有唯一的句柄来标识,但不一定有对应的MFC类对象在内存中.当需要获取Windows对象的对应M ...
- jQuery ztree 自制一套 灰蓝皮肤
jQuery ztree 自制一套 灰蓝皮肤 PNG图片替换官方ztree下img文件中的png图片即可