HDU Ellipse(simpson积分)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2677 Accepted Submission(s):
1208
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 )
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
of integers l and r, mean the L is (l, 0) and R is (r, 0). (-a <= l <= r
<= a).
area of the intersection, accurate to three decimals after the decimal
point.
2 1 -2 2
2 1 0 2
3.142
#include<cstdio>
#include<cmath>
int N;
double a, b, L, R;
double f(double x) {
return * b * sqrt(1.0 - (x * x) / (a * a));
}
double sim(double l, double r) {
return (f(l) + f(r) + 4.0 * f((l + r) / 2.0)) * (r - l) / 6.0;
}
double asr(double l, double r, double eps, double ans) {
double mid = (l + r) / ;
double la = sim(l, mid), ra = sim(mid, r);
if(fabs(la + ra - ans) < eps) return la + ra;
return asr(l, mid, eps / , sim(l, mid)) + asr(mid, r, eps / , sim(mid, r));
}
main() {
scanf("%d", &N);
while(N--) {
scanf("%lf %lf %lf %lf", &a, &b, &L, &R);
printf("%.3lf\n", asr(L, R, 1e-, sim(L, R)));
}
}
HDU Ellipse(simpson积分)的更多相关文章
- 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 【自适应Simpson积分】
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- [BZOJ 2178] 圆的面积并 【Simpson积分】
题目链接:BZOJ - 2178 题目分析 用Simpson积分,将圆按照 x 坐标分成连续的一些段,分别用 Simpson 求. 注意:1)Eps要设成 1e-13 2)要去掉被其他圆包含的圆. ...
- [BZOJ 1502] [NOI2005] 月下柠檬树 【Simpson积分】
题目链接: BZOJ - 1502 题目分析 这是我做的第一道 Simpson 积分的题目.Simpson 积分是一种用 (fl + 4*fmid + fr) / 6 * (r - l) 来拟合 fl ...
- 自适应Simpson积分
自适应Simpson积分 作用 如标题所示,这玩意就是当你不会微积分的时候来求积分的. 总所周知,积分的定义就是函数的某一段与坐标轴之间的面积. 那么,自适应Simpson积分就是一种可以再某些精度下 ...
- 【BZOJ1502】[NOI2005]月下柠檬树 Simpson积分
[BZOJ1502][NOI2005]月下柠檬树 Description 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树 ...
- 【bzoj1502】[NOI2005]月下柠檬树 自适应Simpson积分
题目描述 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月 ...
- BZOJ 2178 圆的面积并 ——Simpson积分
[题目分析] 史上最良心样例,史上最难调样例. Simpson积分硬上. 听说用long double 精度1e-10才能过. 但是double+1e-6居然过了. [代码] #include < ...
随机推荐
- JavaScript 访问对象属性和方法及区别
这篇文章主要介绍了浅析JavaScript访问对象属性和方法及区别的相关资料,仅供参考 属性是一个变量,用来表示一个对象的特征,如颜色.大小.重量等:方法是一个函数,用来表示对象的操作,如奔跑.呼吸. ...
- 10分钟学会Less开发环境搭建与初体验
Less 是一门 CSS 预处理语言,它扩充了 CSS 语言,增加了诸如变量.混合(mixin).函数等功能,让 CSS 更易维护.方便制作主题.扩充. 今天看一下,10分钟能不能手把手快速教会你Le ...
- listview cacheColorHint,listSelector属性
ListView是常用的显示控件,默认背景是和系统窗口一样的透明色,如果给ListView加上背景图片,或者背景颜色时,滚动时listView会黑掉, 原因是,滚动时,列表里面的view重绘时,用的依 ...
- ANN神经网络——Sigmoid 激活函数编程练习 (Python实现)
# ---------- # # There are two functions to finish: # First, in activate(), write the sigmoid activa ...
- 任务十五:零基础JavaScript编码(三)
任务目的 在上一任务基础上继续JavaScript的体验 接触一下JavaScript中的高级选择器 学习JavaScript中的数组对象遍历.读写.排序等操作 学习简单的字符串处理操作 任务描述 参 ...
- How to import Django DB operations out of Django projects
i am not familiar with DB opertions. usually i stroe data to txt and other formats. as DB is more an ...
- 基于按annotation的hibernate主键生成策略
基于按annotation的hibernate主键生成策略 博客分类: Hibernate HibernateJavaJPAOracleMySQL 这里讨论代理主键,业务主键(比如说复合键等)这里不 ...
- js 获取URL中参数
function getQueryString() { var result = location.search.match(new RegExp("[\?\&][^\?\& ...
- [使用经验]cocostudio UI编辑器的裁剪
日志-2015/03/16 描述:在程序使用UI编辑器导出文件的时候,该panel中大于panel的部分都没有显示出来,例如人物,一些特效等 原因:UI编辑器panel都勾上了裁剪 解决:在编辑器中把 ...
- 配置spark集群
配置spark集群 1.配置spark-env.sh [/soft/spark/conf/spark-env.sh] ... export JAVA_HOME=/soft/jdk 2.配置slaves ...