HDU - 1724 Ellipse 自适应辛普森模板
//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 自适应辛普森模板的更多相关文章
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
- hdu 1724 Ellipse —— 自适应辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
- HDU 1724 Ellipse
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- 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 ...
- hdu 1724 Ellipse——辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...
- HDU 1724 Ellipse [辛普森积分]
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
随机推荐
- Docker在线文档收集
极客学院 kubernetes中文社区 易百教程
- XJOI夏令营501训练1——分配工作
传送门:QAQQAQ 题意:某公司有工作人员x1,x2,…,xn ,他们去做工作y1,y2,…,ym(n<=m) ,每个人都能做其中的几项工作,并且对每一项工作都有一个固定的效率.问能否找到一种 ...
- Cesium官方教程8-- 几何体和外观效果
原文地址:https://cesiumjs.org/tutorials/Geometry-and-Appearances/ 几何体和外观效果(Geometry and Appearances) 这篇教 ...
- MySQL数据库--创建表,查询
MySQL创建表: 表(一)Student (学生表): CREATE TABLE `Student` ( `sno` ) DEFAULT NULL, `sname` ) DEFAULT NULL, ...
- myeclipse中tomcat内存大小的设置
刚刚安装了myeclipse9.0,又配置了tomcat7.0,想用ssh框架搭个项目试试tomcat7.0,没想到刚启动项目就会报错,在tomcat6.0中就不会有问题,上网查了那些都不起作用,后来 ...
- 在Jsp中调用静态资源,路径配置问题
在Jsp中调用图片.JS脚本等,针对取得的路径有两种调用方式: 1.放入Body中生成绝对路径(不建议) <%@ page language="java" import=&q ...
- NoSQL 文档数据库
- 如何正确使用 Flink Connector?
本文主要分享 Flink connector 相关内容,分为以下三个部分的内容:第一部分会首先介绍一下 Flink Connector 有哪些.第二部分会重点介绍在生产环境中经常使用的 kafka c ...
- Vue+jquery上拉加载
<ul> <li class="new-list" v-for="item in proarr"> <a :href=" ...
- touch滑动事件---简单小案例
html: <!--导航栏头部--><div class="type_nav"> <ul class="clearfix " v- ...