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. VS code 自定义快捷输入

    本文是从简书复制的, markdown语法可能有些出入, 想看"正版"和更多内容请关注 简书: 小贤笔记 位置 ctrl+shift+p 搜索: snippets 输入类型: 比如 ...

  2. eclipse 内存溢出

    2011年02月22日 星期二 11:14 eclipse.exe -vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M ec ...

  3. ArcEngine交互画线

    代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-- ...

  4. opencv 从摄像头中读取视频并保存(c++版)

    原文:http://blog.csdn.net/zhongshijunacm/article/details/68947890 OpenCV中的视频操作函数如下表所列: VideoCapture Vi ...

  5. c++开发ocx入门实践二

    原文:http://blog.csdn.net/yhhyhhyhhyhh/article/details/51374355         IDE:vs2010,c++,测试工具,vs自带的TstCo ...

  6. Android之自定义View以及画一个时钟

    https://www.2cto.com/kf/201509/443112.html 概述: 当Android自带的View满足不了开发者时,自定义View就发挥了很好的作用.建立一个自定义View, ...

  7. java线程方法join的总结

    虽然关于讨论线程join方法的博客已经很多了,不过个人感觉挺多都讨论得不够全面,所以我觉得有必要对其进行一个全面的总结. 一.作用 Thread类中的join方法的主要作用就是同步,它可以使得线程之间 ...

  8. Excel 函数使用

    字符串 20180613 转为日期  2018-06-13,单元格内输入如下公式 =DATE(LEFT(),MID(,),RIGHT()) IF 函数内的或.与 =IF(AND(A=B,C=D),&q ...

  9. Azkaban3.X的安装(2018年8月19日最新版本)

    参考文章: 1.http://azkaban.github.io/azkaban/docs/latest/ 2.http://blog.csdn.net/gaoqida/article/details ...

  10. 设计模式:装饰器(Decorator)模式

    设计模式:装饰器(Decorator)模式 一.前言    装饰器模式也是一种非常重要的模式,在Java以及程序设计中占据着重要的地位.比如Java的数据流处理,我们可能看到数据流经过不同的类的包装和 ...