博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU1724 Ellipse
阅读量:5864 次
发布时间:2019-06-19

本文共 2176 字,大约阅读时间需要 7 分钟。

 

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

22 1 -2 22 1 0 2

Sample Output

6.2833.142

 

几何

simpson积分强行搞

1 #include
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 const double eps=1e-9; 8 const int mxn=100010; 9 int read(){10 int x=0,f=1;char ch=getchar();11 while(ch<'0' || ch>'9'){
if(ch=='-')f=-1;ch=getchar();}12 while(ch>='0' && ch<='9'){x=x*10-'0'+ch;ch=getchar();}13 return x*f;14 }15 int a,b;16 inline double f(double x){17 return b*sqrt((double)1-(x*x/(double)a/a));18 }19 inline double sim(double l,double r){20 return (r-l)/6*(f(l)+4*f((l+r)/2)+f(r));21 }22 double solve(double l,double r){23 double mid=(l+r)/2;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",2*ans);37 }38 return 0;39 }

 

转载于:https://www.cnblogs.com/SilverNebula/p/6351794.html

你可能感兴趣的文章
NOIP2018退役记
查看>>
学以致用三十三-----django生命周期
查看>>
数据结构-冒泡排序
查看>>
Word揭秘:公式还能这么玩!
查看>>
MathType出现乱码公式怎么恢复
查看>>
Android--绑定服务调用服务的方法
查看>>
基于Elasticsearch的自定义评分算法扩展
查看>>
为什么DOM操作很慢
查看>>
Linux动态链接库的使用
查看>>
Struts+spring+Hibernate 制作一个简单的登录验证
查看>>
遍历接口参数,自动计算url并进行签名
查看>>
Git安装
查看>>
DOM 的事件对象(event)
查看>>
IdentityServer4之Implicit(隐式许可)
查看>>
第九章 CSS-DOM
查看>>
Git修改最后一次提交
查看>>
Exchange企业实战技巧(4)配置登录OWA不需要输入域名称
查看>>
戏说Nginx(四)
查看>>
八年Android开发,从码农到架构师分享我的技术成长之路
查看>>
C# 利用Jmail接收邮件
查看>>