HDU 1724 Ellipse [辛普森积分]
Ellipse
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1868 Accepted Submission(s): 792
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 )
2 1 -2 2
2 1 0 2
可以计算椭圆面积了哈哈
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const double eps=1e-; double a,b,l,r;
inline double F(double x){
return sqrt((a*a-x*x)/(a*a))*b;
}
inline double cal(double l,double r){
return (F(l)+F(r)+*F((l+r)/))*(r-l)/;
}
double Simpson(double l,double r,double now){
double mid=(l+r)/,p=cal(l,mid),q=cal(mid,r);
if(abs(now-p-q)<eps) return now;
else return Simpson(l,mid,p)+Simpson(mid,r,q);
} int main(int argc, const char * argv[]) {
int T;scanf("%d",&T);
while(T--){
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
l=max(l,-a);r=min(r,a);
printf("%.3f\n",*Simpson(l,r,cal(l,r)));
} return ;
}
HDU 1724 Ellipse [辛普森积分]的更多相关文章
- hdu 1724 Ellipse——辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...
- 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 ——Simpson积分
[题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...
- HDU 1724 Ellipse (自适应辛普森积分)
题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical tes ...
- hdu 1724 Ellipse —— 自适应辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 ...
- HDU 1724 Ellipse 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- HDU 1724 Ellipse(数值积分の辛普森公式)
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC ...
- HDU 1724 Ellipse 自适应simpson积分
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 ...
- hdu 1724 : Ellipse 【Simpson积分】
题目链接 题意:给出椭圆方程中的a和b,再给出l.r,求l到r的积分的二倍. 输出时要求精度控制为保留到小数点后3位,如下代码中,eps设为1e-9 1e-8时均TLE,1e-4可以AC,1e-3会W ...
随机推荐
- 使用setTimeout实现setInterval
setInterval = () =>{ console.log(1) //使用递归 setTimeout(setInterval,1000); }; setInterval()
- [国嵌笔记][036][关闭MMU和CACHE]
关闭MMU和CACHE 1.Cache是一种容量小,但存取速度非常快的存储器,它保存最近用到的存储器中数据的拷贝.按功能分为ICache(指令Cache)和DCache(数据Cache) 2.虚拟地址 ...
- vim&vi在编辑的时候突然卡死,不接收输入问题的解决
多方查找无果,看了官方解释如下: "CTRL-S and CTRL-Q are called flow-control characters. They represent an antiq ...
- Vuthink正确安装过程
1. 下载项目vuethink,本例将项目放置website文件下. 2. 后台搭建 本地建站–>以phpstudy为例 1) 新建站点域名 <Virtual ...
- 单KEY业务,数据库水平切分架构实践
本文将以"用户中心"为例,介绍"单KEY"类业务,随着数据量的逐步增大,数据库性能显著降低,数据库水平切分相关的架构实践: 如何来实施水平切分 水平切分后常见的 ...
- mysql的水平拆分和垂直拆分
转:http://www.cnblogs.com/sns007/p/5790838.html 1,水平分割: 例:QQ的登录表.假设QQ的用户有100亿,如果只有一张表,每个用户登录的时候数据库都要从 ...
- MySQL大表优化方案
转:https://segmentfault.com/a/1190000006158186?hmsr=toutiao.io&utm_medium=toutiao.io&utm_sour ...
- 非线性规划带约束-scipy.optimize.minimize
# coding=utf-8 from scipy import optimize import numpy as np def get(args): a, b, c, d, e, f, g, h = ...
- common-logging源码解析
OK,现在我们来研究下common-logging的源码.这篇博客有参照上善若水的博客,感谢他的无私分享. 先来随便扯点吧,貌似所有这些流行的Logging框架都和Log4J多少有点关系(不太确定Co ...
- 比较Maven和Ant
从今天开始,整理maven一系列. Maven 它是什么? 如何回答这个问题要看你怎么看这个问题. 绝大部分Maven用户都称Maven是一个"构建工具":一个用来把源代码构建成可 ...