HDU 1724 Ellipse
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 )
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
each case, output one line containing a float, the area of the
intersection, accurate to three decimals after the decimal point.
#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的更多相关文章
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
- HDU 1724 Ellipse 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- hdu 1724 Ellipse——辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...
- hdu 1724 Ellipse —— 自适应辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...
- HDU 1724 Ellipse(数值积分の辛普森公式)
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- HDU 1724 Ellipse [辛普森积分]
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
- HDU 1724 Ellipse ——Simpson积分
[题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...
随机推荐
- 【iOS】单元测试
iOS单元测试(作用及入门提升) 字数1704 阅读16369 评论26 喜欢247 由于只是一些简单实用的东西,学学还是挺不错的.其实单元测试用的好,开发起来也会快很多.单元测试对于我目前来说,就是 ...
- JAVA中GridBagLayout布局管理器应用详解
很多情况下,我们已经不需要通过编写代码来实现一个应用程序的图形界面,而是通过强大的IDE工具通过拖拽辅以简单的事件处理代码即可很轻松的完成.但是我们不得不面对这样操作存在的一些问题,有时候我们希望能够 ...
- [USACO13JAN] Seating
https://www.luogu.org/problem/show?pid=3071 题目描述 To earn some extra money, the cows have opened a re ...
- Winserver+Apache+django部署
废话不多说,干活直接上. winserver2012 + django2.0.1 + apache 部署过程 python ==> 3.4 64位 https://www.python.org/ ...
- float、absolute、inline-block三者区别
0.前言 float属性在css2中是一个热门的属性,被广泛应用于布局之中,同时由于不当使用float带来的问题也非常多,本文结合自己对float的理解以及实际项目中碰到float的相关问题,做一个详 ...
- Linux的安装和使用技巧
LinuxCentOs开始设置一个普通的用户,如果想进入root用户,可以su然后设置密码,然后第二次再次输入su,然后输入相同的密码就可以进去了 有很多命令需要在root下才能执行,但是在创建时却是 ...
- CentOS 7 GUI图形界面安装
在此之前先获取root权限,进行以下命令: 1. 在命令行下输入下面的命令来安装Gnome包: yum groupinstall "GNOME Desktop" "Gra ...
- mysql常用命令整理
#不压缩备份 mysqldump -u root -p userpassword databasename > /tmp/backupfile.sql #压缩备份 mysqldump -u ro ...
- c#动态加载卸载DLL
前段时间工作的时候遇到一个问题.就是需要每次启动程序的时候动态替换掉某个dll,所以就百度了这方面的资料.这次记录下来让自己以后可以看. 根据自己的理解,动态卸载dll需要有以下条件: 1:dll在加 ...
- SpringCloud的EurekaClient : 客户端应用访问注册的微服务(有断路器场景)
演示客户端应用如何访问注册在EurekaServer里的微服务 一.概念和定义 采用Ribbon或Feign方式访问注册到EurekaServer中的微服务.1.Ribbon实现了客户端负载均衡,2. ...