Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2677    Accepted Submission(s):
1208

Problem Description
Math is important!! Many students failed in 2+2’s
mathematical test, so let's AC this problem to mourn for our lost
youth..
Look this sample picture:

A ellipses in the plane and
center in point O. the L,R lines will be vertical through the X-axis. The
problem is calculating the blue intersection area. But calculating the
intersection area is dull, so I have turn to you, a talent of programmer. Your
task is tell me the result of calculations.(defined PI=3.14159265 , The area of
an ellipse A=PI*a*b )

 
Input
Input may contain multiple test cases. The first line
is a positive integer N, denoting the number of test cases below. One case One
line. The line will consist of a pair of integers a and b, denoting the ellipse
equation , A pair
of integers l and r, mean the L is (l, 0) and R is (r, 0). (-a <= l <= r
<= a).
 
Output
For each case, output one line containing a float, the
area of the intersection, accurate to three decimals after the decimal
point.
 
Sample Input
2
2 1 -2 2
2 1 0 2
 
Sample Output
6.283
3.142
 
Author
威士忌
 
Source
 
Recommend
lcy   |   We have carefully selected several similar
problems for you:  1722 1727 1721 1726 1725 
 
 
直接强上simpso积分就行
稍微有点卡精度
 
#include<cstdio>
#include<cmath>
int N;
double a, b, L, R;
double f(double x) {
return * b * sqrt(1.0 - (x * x) / (a * a));
}
double sim(double l, double r) {
return (f(l) + f(r) + 4.0 * f((l + r) / 2.0)) * (r - l) / 6.0;
}
double asr(double l, double r, double eps, double ans) {
double mid = (l + r) / ;
double la = sim(l, mid), ra = sim(mid, r);
if(fabs(la + ra - ans) < eps) return la + ra;
return asr(l, mid, eps / , sim(l, mid)) + asr(mid, r, eps / , sim(mid, r));
}
main() {
scanf("%d", &N);
while(N--) {
scanf("%lf %lf %lf %lf", &a, &b, &L, &R);
printf("%.3lf\n", asr(L, R, 1e-, sim(L, R)));
}
}

HDU Ellipse(simpson积分)的更多相关文章

  1. hdu 1724 Ellipse simpson积分

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

  2. HDU 1724 Ellipse ——Simpson积分

    [题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...

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

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

  4. [BZOJ 2178] 圆的面积并 【Simpson积分】

    题目链接:BZOJ - 2178 题目分析 用Simpson积分,将圆按照 x 坐标分成连续的一些段,分别用 Simpson 求. 注意:1)Eps要设成 1e-13  2)要去掉被其他圆包含的圆. ...

  5. [BZOJ 1502] [NOI2005] 月下柠檬树 【Simpson积分】

    题目链接: BZOJ - 1502 题目分析 这是我做的第一道 Simpson 积分的题目.Simpson 积分是一种用 (fl + 4*fmid + fr) / 6 * (r - l) 来拟合 fl ...

  6. 自适应Simpson积分

    自适应Simpson积分 作用 如标题所示,这玩意就是当你不会微积分的时候来求积分的. 总所周知,积分的定义就是函数的某一段与坐标轴之间的面积. 那么,自适应Simpson积分就是一种可以再某些精度下 ...

  7. 【BZOJ1502】[NOI2005]月下柠檬树 Simpson积分

    [BZOJ1502][NOI2005]月下柠檬树 Description 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树 ...

  8. 【bzoj1502】[NOI2005]月下柠檬树 自适应Simpson积分

    题目描述 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月 ...

  9. BZOJ 2178 圆的面积并 ——Simpson积分

    [题目分析] 史上最良心样例,史上最难调样例. Simpson积分硬上. 听说用long double 精度1e-10才能过. 但是double+1e-6居然过了. [代码] #include < ...

随机推荐

  1. .NET开源工作流RoadFlow-Bug修改-1.8.2表单验证时ueditor编辑非空验证无效

    RoadFlow生成的表单,Ueditor编辑器不能进行非空验证的BUG修改: 1.修改控制器:WorkFlowFormDesignerController红框处: 2.修改js文件:Scripts/ ...

  2. 【Python】多重赋值之值互换

    右边的值先确定,然后再开始向左赋值 s = 1 t = 2 s,t = t,s print s print t >>> 2 >>> 1 区分 s = t t = s ...

  3. 微软宣布在Azure上支持更多的开放技术和选择

    微软和我都热爱Linux,并且就在情人节过去几天之后,我非常高兴能用几个激动人心的消息来表达这种对Linux的热爱,您将会看到在Azure上的云部署将具有更加开放的选择性和灵活性. 这些激动人心的消息 ...

  4. Angular4 微信的坑

    1.不要重置对象的引用!(重置只应该在组件或服务的初始化时) why:会使页面产生闪烁 2.不要给图片绑定一个空的值或空的图片引用(如果值从服务器异步过来,那应该在初始化时给它一个默认值) why:会 ...

  5. dia无法输入中文的解决

    安装dia后无法输入中文,解决如下: 修改/usr/bin/dia #dia-normal --integrated "$@" dia-normal "$@"

  6. 记录两篇关于linux设置ssh登录 和NAT网络模式下访问

    https://blog.csdn.net/java_dotar_01/article/details/76942563 https://blog.csdn.net/jiuduan2009/artic ...

  7. Linux系统中while管道的

    因为项目从AIX系统迁移到了RedHat系统,之前写过的一段Shell脚本不能成功运行,经过分析,锁定了关键代码如下: readFileContent(){ currentFile=$ fileSho ...

  8. ZooKeeper介绍与环境搭建

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一致性服务的软件,提供的功 ...

  9. 阅读优秀的JAVA模板引擎Beetl的使用说明有感

    由于项目需要,对包括Beetl在内的JAVA模板引擎技术进行了学习 Beetl是由国人李家智(昵称闲大赋)开发的一款高性能JAVA模板引擎,对标产品是Freemaker 感慨于近几年国内开源项目的蓬勃 ...

  10. BZOJ2662:[BJWC2012]冻结(分层图最短路)

    Description “我要成为魔法少女!”     “那么,以灵魂为代价,你希望得到什么?” “我要将有关魔法和奇迹的一切,封印于卡片之中„„”        在这个愿望被实现以后的世界里,人们享 ...