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. go的编译与重启

    ps -ef|grep pro-name| grep -v grep|awk '{print $2}'|xargs kill -9 > /dev/null go build nohup ./xe ...

  2. js-滚动到指定位置导航栏固定顶部

    最近整理一下之前做的一个项目,把滚动条动态固定顶部的代码整理出来和大家分享,上代码 <!DOCTYPE html> <html> <head> <meta c ...

  3. EMSAscript

    1.javaScript 中const.var.let区别 const 定义的变量不可修改 而且必须初始化 =>解决闭包变量污染问题 var 定义的变量可以修改 如果不初始化则默认值为undef ...

  4. SpringMVC学习(五)——拦截器示例

    部分内容摘自开涛的<跟我学SpringMVC.PDF> 拦截器,本质类似于AOP,主要的应用场景: 1.日志记录:记录请求信息的日志,以便进行信息监控.信息统计.计算PV等. 2.权限检查 ...

  5. mongodb数据库备份恢复-windows系统

    备份语法: mongodump命令脚本语法如下: >mongodump -h dbhost -d dbname -o dbdirectory -h: MongDB所在服务器地址,例如:127.0 ...

  6. DOS下常用命令

    0,想进入某个驱动器,直接输入盘符即可.如:“d:”1,CD--进入指定目录 2,cls--清除显示器屏幕上的内容,使DOS提示符到屏幕左上角. 3,time--显示和设置DOS的系统时间 4,dir ...

  7. Oracle sql trace用法

    sql_trace是oracle提供的一个非常好的跟踪工具,主要用来检查数据库的异常情况,通过跟踪数据库的活动,找到有问题的语句. 一.概述:    SQL_TRACE是Oracle的一个非常强大的工 ...

  8. [转]Android开源项目收藏分享

    转自:http://blog.csdn.net/dianyueneo/article/details/40683285 Android开源项目分类汇总 如果你也对开源实现库的实现原理感兴趣,欢迎 St ...

  9. 理解Underscore中的节流函数

    上一篇中讲解了Underscore中的去抖函数(_.debounced),这一篇就来介绍节流函数(_.throttled). 经过上一篇文章,我相信很多人都已经了解了去抖和节流的概念.去抖,在一段连续 ...

  10. Allocate exception for servlet ValidateUsernameServlet 异常

    如果eclipse无法对类文件进行编译那么运行时就会发生 Allocate exception for servlet ValidateUsernameServlet 异常,说找不到类.