HDU1724 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 )
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 ;
}
HDU1724 Ellipse的更多相关文章
- 【自适应辛普森积分】hdu1724 Ellipse
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU1724 Ellipse(数值积分)
补一下一些小盲区,譬如simpson这种数值积分的方法虽然一直知道,但是从未实现过,做一道例题存一个模板. #pragma warning(disable:4996) #include<iost ...
- [svg翻译教程]椭圆(ellipse元素)和线(line元素)
line 先看个例子,这是svg中最简单的线 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http:/ ...
- [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 ...
- svg学习(五)ellipse
<ellipse> 标签 <ellipse> 标签可用来创建椭圆.椭圆与圆很相似.不同之处在于椭圆有不同的 x 和 y 半径,而圆的 x 和 y 半径是相同的. <?xm ...
- HDU 1724 Ellipse(数值积分の辛普森公式)
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- Kinetic使用注意点--ellipse
new Ellipse(config) 参数: config:包含所有配置项的对象. { radius: "半径,可以用数字a.数组[a,b]或对象{x:a,y:b}来表示" } ...
- HDU 2876 Ellipse, again and again
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://acm.hdu.edu.cn/showproblem.php ...
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
随机推荐
- OI算法复习汇总
各大排序 图论: spfa floyd dijkstra *拉普拉斯矩阵 hash表 拓扑排序 哈夫曼算法 匈牙利算法 分块法 二分法 费马小定理: a^(p-1) ≡1(mod p) 网络流 二分图 ...
- Golang Json测试
结构体是谷歌搜索API package main import ( "encoding/json" "fmt" "io/ioutil" &q ...
- k8s 基于NFS部署storageclass pv自动供给
在k8s中部署有状态应用时,通常需要做数据持久化存储. 后端存储的方式有以下几种: 1.基于宿主机本地的存储方式: (重启pod时,若pod被调度到其他节点上,尽管原来节点上的数据不会丢失,但是其他节 ...
- 嵌入式入门学习笔记3:[转]编译linux
摘自:https://blog.csdn.net/baidu_24256693/article/details/80115354 编译Linux是什么意思? Linux内核是Linux操作系统的核心, ...
- NXP低功耗蓝牙集成芯片QN9080C的时钟配置
/*************************************************************************************************** ...
- MVC&JQuery如何根据List动态生成表格
背景:在编码中,常会遇到根据Ajax的结果动态生成Table的情况,本篇进行简要的说明.这已经是我第4.5篇和Ajax有关的随笔了,互相之间有很多交叠的地方,可自行参考. 后台代码如下: public ...
- Linux学习-分析登录档
CentOS 预设提供的 logwatch 不过,要了解系统的状态,还是得要分析整个登录档才行~ 事实上, 目前已经有相当多的登录档分析工具,例如 CentOS 7.x 上面预设的 logwatch ...
- Linux学习-登录档的轮替(logrotate)
rsyslogd 利用的是 daemon 的方式来启动的, 当有需求的时候立刻就会被执行的,但是 logrotate 却是在规定的时间到了之后才来进行登录档的轮 替, 所以这个 logrotate 程 ...
- 15年多校第一场七题hdu5294
要做这题,先要明白图的割,说白了就是 为了让原点无法到汇点要删几条边(之所以叫割,就是在图面上切一刀,减掉最小的边是原点和汇点成为两个集合),想到了割先放着一会用. 题中说只有沿最短路走才有可能追上, ...
- 对java多线程的一些浅浅的理解
作为一名JAVA初学者,前几天刚刚接触多线程这个东西,有了些微微的理解想写下来(不对的地方请多多包涵并指教哈). 多线程怎么写代码就不说了,一搜一大堆.说说多线程我认为最难搞的地方,就是来回释放锁以及 ...