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 ;
}

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. 类扩展Extension

    延展(Extension):在本类里声明私有方法. 1:延展定义的方法是在implemetation中. 2:声明的方法是私有方法. 3:延展中声明的方法可以不实现. #import "Ho ...

  2. NOIP2013 表达式求值

    题目描述 Description 给定一个只包含加法和乘法的算术表达式,请你编程计算表达式的值. 输入描述 Input Description 输入仅有一行,为需要你计算的表达式,表达式中只包含数字. ...

  3. linux关于yum

    yum仓库设置:1.cd /etc/yum.repos.d yum仓库 2.CentOS-Base.repo 网络源 CentOS-Media.repo 光盘源 设置 vi CentOS-Media. ...

  4. LeetCode945-使数组唯一的最小增量

    问题:使数组唯一的最小增量 给定整数数组 A,每次 move 操作将会选择任意 A[i],并将其递增 1. 返回使 A 中的每个值都是唯一的最少操作次数. 示例 1: 输入:[1,2,2] 输出:1 ...

  5. Buffered Channels and Worker Pools

    原文链接:https://golangbot.com/buffered-channels-worker-pools/ buffered channels 带有缓冲区的channel 只有在缓冲区满之后 ...

  6. yield关键字有什么作用

    所属网站分类: python基础 > 语句 作者:goodbody 链接: http://www.pythonheidong.com/blog/article/10/ 来源:python黑洞网  ...

  7. python并发编程之线程(创建线程,锁(死锁现象,递归锁),GIL锁)

    什么是线程 进程:资源分配单位 线程:cpu执行单位(实体),每一个py文件中就是一个进程,一个进程中至少有一个线程 线程的两种创建方式: 一 from threading import Thread ...

  8. 数学基础:HUD1406-完数

    完数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descript ...

  9. ACM-ICPC 2017 Asia Urumqi A. Coins

    Alice and Bob are playing a simple game. They line up a row of n identical coins, all with the heads ...

  10. 前端 五——ajax

    内容概要: 1.ajax的特点 2.基于JS的ajax 3.基于jQuery的ajax 1.特点: 局部刷新 异步传送(交互) 缺点: (1)无形中向服务器发送的请求次数太多,导致服务器压力增大. ( ...