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

2
2 1 -2 2
2 1 0 2

Sample Output

6.283
3.142

几何

simpson积分强行搞

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const double eps=1e-;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*-''+ch;ch=getchar();}
return x*f;
}
int a,b;
inline double f(double x){
return b*sqrt((double)-(x*x/(double)a/a));
}
inline double sim(double l,double r){
return (r-l)/*(f(l)+*f((l+r)/)+f(r));
}
double solve(double l,double r){
double mid=(l+r)/;
double res=sim(l,r);
// printf("l:%.3f r:%.3f res:%.3f\n",l,r,res);
if(fabs(sim(l,mid)+sim(mid,r)-res)<=eps)return res;
return solve(l,mid)+solve(mid,r);
}
int main(){
int T=read();
double l,r;
while(T--){
a=read();b=read();
l=read();r=read();
double ans=solve(l,r);
printf("%.3f\n",*ans);
}
return ;
}

最新文章

  1. ASP.NET MVC 视图(三)
  2. Unity自动寻路Navmesh之高级
  3. NULL指针、零指针、野指针
  4. chrome浏览器调用 ajax 提示net::ERR_INCOMPLETE_CHUNKED_ENCODING问题解决方案,以及 Response.Close 和 Response.End 的一些问题。
  5. Struts2进行url重写
  6. MFC中控制COMBOBOX控件的下拉框高度
  7. Windows 2003/2008更改远程桌面端口脚本
  8. Part 3 talking about constraint in sql
  9. 解决maven仓库有jar包但是maven程序无法下载仓库jar包
  10. 类(class)能不能自己继承自己(转)
  11. Java 并发 线程的优先级
  12. foreach 循环的应用传值
  13. 关于CGI:Tomcat、PHP、Perl、Python和FastCGI之间的关系
  14. JDBC(二)之JDBC处理CLOB和BLOB及事务与数据库元数据获取
  15. requests-post请求
  16. Spring 初学笔记
  17. 记一次 net 使用 data.oracleclient 使用错误OCIEnvCreate 失败, 返回代码为-1
  18. 关闭AutoCAD 2019快速访问工具栏的web和moblie保存文件功能
  19. 【转】ubuntu 12.04下如何开启 NFS 服务 &amp; 设置
  20. php 文件上传类,功能相当齐全,留作开发中备用吧。

热门文章

  1. Bootstrap 页面标题(Page Header)
  2. Linux curl 详解
  3. nginx日志相关优化安全
  4. PHP安装Xcache扩展
  5. Kubernetes的主要功能
  6. 用session模拟登陆,手动输入验证码
  7. debian使用ibus
  8. IAR调试时出现IAR one or more breakpoints could not be set and have been disabled的解决办法
  9. 20,序列化模块 json,pickle,shelve
  10. tomcat6-endpoint设计