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 < ...
随机推荐
- 关于github改名问题
不喜欢github显示的目录名字于是百度了下,更改过程,记录下来,方便日后查看! 首页右上角点击出来菜单,找到Settings按钮点击 左侧找到Account账号菜单点击 找到change usern ...
- css3阴影
<!DOCTYPE html> <html> <head> <style> div { margin-top:100px; margin-left:10 ...
- 异步nodejs代码的同步样子写法样例
异步nodejs代码的同步样子写法样例 js的异步嵌套太深代码将不好看.尤其在用node的时候这种情况会大量出现. 这里用node连接redis,做一个用户注册的简单例子来说明.例如用redis做存储 ...
- GitHub教程(一) 使用指南
刚进公司上班的时候,技术总监让我熟悉一下Git(分布式版本控制工具)操作命令和GitHub(代码托管平台),说实话之前我也没有具体使用过Git工具,但是GitHub我还是注册过账号的.在练习将本地仓库 ...
- SQL Server ->> T-SQL查询面试题之实例版
1 - 3 题: 数据表结构: OrderID ProductID OrderDate SaleAmount 1 1 2015-01-01 100 2 6 2015-02-01 900 3 1 ...
- 24点-code1
#include <iostream> #include <string> #include <cstdlib> #include <cmath> us ...
- RabbitMq ack 与 nack
1.ack 移除 2.nack 移除再次发送队列
- Redis入门实例(Redis+Sprint+maven创建工程)
一.>创建一个maven工程应用和相关配置:Redis_study,创建工程应用过程略 1.>配置pom.xml:文件内容如下 <project xmlns="http:/ ...
- 如何使用Flashfxp上传下载文件
一.首先您本地电脑需要安装flashfxp软件,您可以通过百度搜索下载. 二.我们打开flashfxp,然后在右上角点击“会话”,再点击“快速连接”,如下图. 三.弹出“如下图”窗口.请输入FTP连接 ...
- zt 李鸿章听过《彩云追月》?
ZT 李鸿章听过<彩云追月>? 2013-05-11 09:35:52 编辑 删除 归档在 观世上之音 | 浏览 1041 次 | 评论 1 条 尝试在网上找一点有关<彩云追月> ...