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 )

InputInput 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).OutputFor each case, output one line containing a float, the area of the intersection, accurate to three decimals after the decimal point.Sample Input

  1. 2
  2. 2 1 -2 2
  3. 2 1 0 2

Sample Output

  1. 6.283
  2. 3.142

几何

simpson积分强行搞

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<cmath>
  6. using namespace std;
  7. const double eps=1e-;
  8. const int mxn=;
  9. int read(){
  10. int x=,f=;char ch=getchar();
  11. while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
  12. while(ch>='' && ch<=''){x=x*-''+ch;ch=getchar();}
  13. return x*f;
  14. }
  15. int a,b;
  16. inline double f(double x){
  17. return b*sqrt((double)-(x*x/(double)a/a));
  18. }
  19. inline double sim(double l,double r){
  20. return (r-l)/*(f(l)+*f((l+r)/)+f(r));
  21. }
  22. double solve(double l,double r){
  23. double mid=(l+r)/;
  24. double res=sim(l,r);
  25. // printf("l:%.3f r:%.3f res:%.3f\n",l,r,res);
  26. if(fabs(sim(l,mid)+sim(mid,r)-res)<=eps)return res;
  27. return solve(l,mid)+solve(mid,r);
  28. }
  29. int main(){
  30. int T=read();
  31. double l,r;
  32. while(T--){
  33. a=read();b=read();
  34. l=read();r=read();
  35. double ans=solve(l,r);
  36. printf("%.3f\n",*ans);
  37. }
  38. return ;
  39. }

HDU1724 Ellipse的更多相关文章

  1. 【自适应辛普森积分】hdu1724 Ellipse

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

  2. HDU1724 Ellipse(数值积分)

    补一下一些小盲区,譬如simpson这种数值积分的方法虽然一直知道,但是从未实现过,做一道例题存一个模板. #pragma warning(disable:4996) #include<iost ...

  3. [svg翻译教程]椭圆(ellipse元素)和线(line元素)

    line 先看个例子,这是svg中最简单的线 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http:/ ...

  4. [javascript svg fill stroke stroke-width rx ry ellipse 属性讲解] svg fill stroke stroke-width ellipse 绘制椭圆属性讲解

    <!DOCTYPE html> <html lang='zh-cn'> <head> <title>Insert you title</title ...

  5. svg学习(五)ellipse

    <ellipse> 标签 <ellipse> 标签可用来创建椭圆.椭圆与圆很相似.不同之处在于椭圆有不同的 x 和 y 半径,而圆的 x 和 y 半径是相同的. <?xm ...

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

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

  7. Kinetic使用注意点--ellipse

    new Ellipse(config) 参数: config:包含所有配置项的对象. { radius: "半径,可以用数字a.数组[a,b]或对象{x:a,y:b}来表示" } ...

  8. HDU 2876 Ellipse, again and again

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://acm.hdu.edu.cn/showproblem.php ...

  9. hdu 1724 Ellipse simpson积分

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

随机推荐

  1. PayPal为什么从Java迁移到Node.js 性能提高一倍 文件代码减少44%

    大家都知道PayPal是另一家迁移到Node.js平台的大型公司,Jeff Harrell的这篇博文 Node.js at PayPal  解释了为什么从Java迁移出来的原因: 开发效率提高一倍(2 ...

  2. shell脚本,awk取奇数行与偶数行方法。

    第一种方法: 第二种方法: 第三种方法:

  3. 01_6_SERVLET如何从上一个页面取得参数

    01_6_SERVLET如何从上一个页面取得参数 1. sevlet实现 public void doGet(HttpServletRequest request, HttpServletRespon ...

  4. 【主席树】bzoj1112: [POI2008]砖块Klo

    数据结构划一下水 Description N柱砖,希望有连续K柱的高度是一样的. 你可以选择以下两个动作 1:从某柱砖的顶端拿一块砖出来,丢掉不要了. 2:从仓库中拿出一块砖,放到另一柱.仓库无限大. ...

  5. golang 函数的特殊用法

    1.可以复用一些写法.经常在单元测试过程中需要new一些对象可以new的操作抽离出来 package main import "fmt" type S struct { } fun ...

  6. 探讨2018年最受欢迎的15顶级Python库!

    近日,数据科学网站 KDnuggets 评选出了顶级 Python 库 Top15,领域横跨数据科学.数据可视化.深度学习和机器学习.如果本文有哪些遗漏,你可以在评论区补充. 图 1:根据 GitHu ...

  7. UVALive - 8292 (法里数列)

    参考博客:zro https://blog.csdn.net/alusang/article/details/81840944 orz 给你一个分母 m 和一个浮点数 x,让你求出一个分母不超过 m ...

  8. ACM训练联盟周赛 A. Teemo's bad day

    65536K   Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his homework ...

  9. python format 用法详解

    format 用法详解 不需要理会数据类型的问题,在%方法中%s只能替代字符串类型 单个参数可以多次输出,参数顺序可以不相同 填充方式十分灵活,对齐方式十分强大 官方推荐用的方式,%方式将会在后面的版 ...

  10. selenium 自动化测试 Chrome 大于 63 版本 不能重定向问题解决办法

    Chrome 一些信息: Chrome 63 以后,浏览器默认屏蔽了重定向 Chrome 63 版本,设置了禁止更新,有些情况还是会更新到最新版本 解决过程: 在博客上查到  selenium 里 给 ...