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
自适应辛普森的模板
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double pi=acos(-1.0);
double a,b;
double F(double x)
{
return b*sqrt(-x*x/(a*a));
}
double simpson(double l,double r)
{
return (r-l)*(F(l)+*F((l+r)/2.0)+F(r))/6.0;
}
double asr(double l,double r,double eps,double A)
{
double mid=(l+r)/2.0;
double LS=simpson(l,mid),RS=simpson(mid,r);
if (fabs(LS+RS-A)<=*eps) return LS+RS+(LS+RS-A)/15.0;
return asr(l,mid,eps/,LS)+asr(mid,r,eps/,RS);
}
int main()
{double eps=1e-;
int T;
double l,r;
cin>>T;
while (T--)
{
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
printf("%.3lf\n",asr(l,r,eps,simpson(l,r))*2.0);
}
}

HDU 1724 Ellipse的更多相关文章

  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 (自适应辛普森积分)

    题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...

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

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

  4. hdu 1724 Ellipse——辛普森积分

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...

  5. hdu 1724 Ellipse —— 自适应辛普森积分

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...

  6. HDU 1724 Ellipse(数值积分の辛普森公式)

    Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...

  7. HDU 1724 Ellipse [辛普森积分]

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

  8. HDU 1724 Ellipse 自适应simpson积分

    simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...

  9. HDU 1724 Ellipse ——Simpson积分

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

随机推荐

  1. Flask 扩展 国际化 本地化

    pip install flask-babel 先初始化一个Flask-Babel的实例 from flask import Flask from flask.ext.babel import Bab ...

  2. python array 使用创建10万浮点数

    from array import array from random floats = array('d',random((for i in range(10**7)) fp = open('flo ...

  3. scrapy 修改URL爬取起始位置

    import scrapy from Autopjt.items import myItem from scrapy.http import Request class AutospdSpider(s ...

  4. 在wamp集成环境下安装laravel5.2.*框架

    虽然官方一直强烈推荐使用homestead,但是这个相对麻烦一点,所以我还是选择使用wamp集成开发环境.还有这里我只讲解windows系统下的安装,其他例如mac或linux就不写了,此文章是面向刚 ...

  5. BEM 中文翻译

    BEM 原文请看 getBEM Introduction(介绍) Block 独立实体,独立的意义 Examples:header, container, menu, checkbox, input ...

  6. Python之旅.第三章.函数4.01/4.02

    一.三元表达式 #普通的判断大小函数def max2(x,y): if x > y: return x else: return yres=max2(10,11)print(res)x=12y= ...

  7. python小练习之二

    title: python小练习之二 tags: 新建,模板,小书匠 grammar_cjkRuby: true --- python小练习之二 需求:实现用户登录,用户名和密码保存到文件里,连续输入 ...

  8. 怎么用DreamWare新建立一个静态网站的站点

    可以上面的图可以看出首先需要用F8确定这个文件是勾选的,然后在D盘建立"华为"文件夹,然后在里面建js,css,image文件夹,然后在DW里面点击站点 然后点击管理站点,有一个新 ...

  9. python3 常用模块

    一.time与datetime模块 在Python中,通常有这几种方式来表示时间: 时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量.我们 ...

  10. linux下xargs和管道的区别

    管道将前面的标准输出作为后面的标准输入,xargs则将标准输入作为命令的参数 一.简介 1.背景 之所以能用到这个命令,关键是由于很多命令不支持|管道来传递参数,而日常工作中有有这个必要,所以就有了x ...