acdream:Andrew Stankevich Contest 3:Two Cylinders:数值积分
Two Cylinders
Problem Description
In this problem your task is very simple.
Consider two infinite cylinders in three-dimensional space, of radii R1 and R2 respectively, located in such a way that their axes intersect and are perpendicular.
Your task is to find the volume of their intersection.
Input
Output
Sample Input
1 1
Sample Output
5.3333
Source
#include<cstdio>
#include<cmath>
#include <algorithm>
using namespace std; double r1,r2; // simpson公式用到的函数,就是待积分函数
double F(double x)
{
return sqrt(r1*r1-x*x)*sqrt(r2*r2-x*x);
} // 三点simpson法。这里要求F是一个全局函数
double simpson(double a, double b)
{
double c = a + (b-a)/;
return (F(a)+*F(c)+F(b))*(b-a)/;
} // 自适应Simpson公式(递归过程)。已知整个区间[a,b]上的三点simpson值A
double asr(double a, double b, double eps, double A)
{
double c = a + (b-a)/;
double L = simpson(a, c), R = simpson(c, b);
if(fabs(L+R-A) <= *eps) return L+R+(L+R-A)/15.0;
return asr(a, c, eps/, L) + asr(c, b, eps/, R);
} // 自适应Simpson公式(主过程)
double asr(double a, double b, double eps)
{
return asr(a, b, eps, simpson(a, b));
} // 用自适应Simpson公式计算积分数值
double getValue()
{ return asr(, r1, 1e-)*; // 第一第二个参数为积分区间,第三个参数为精度
} int main()
{
while(~scanf("%lf%lf",&r1,&r2))
{
if(r1>r2)
swap(r1,r2);
printf("%.10f\n",getValue());
}
return ;
}
acdream:Andrew Stankevich Contest 3:Two Cylinders:数值积分的更多相关文章
- GYM 100608G 记忆化搜索+概率 2014-2015 Winter Petrozavodsk Camp, Andrew Stankevich Contest 47 (ASC 47)
https://codeforces.com/gym/100608 题意: 两个人玩游戏,每个人有一个长为d的b进制数字,两个人轮流摇一个$[0,b-1]$的骰子,并将选出的数字填入自己的d个空位之中 ...
- Andrew Stankevich's Contest (1)
Andrew Stankevich's Contest (1) 打一半出门了,回来才补完了...各种大数又不能上java..也是蛋疼无比 A:依据置换循环节非常easy得出要gcd(x, n) = 1 ...
- Andrew Stankevich's Contest (21) J dp+组合数
坑爹的,,组合数模板,,, 6132 njczy2010 1412 Accepted 5572 MS 50620 KB C++ 1844 B 2014-10-02 21:41:15 J - 2-3 T ...
- 【模拟ACM排名】ZOJ-2593 Ranking (Andrew Stankevich’s Contest #5)
真心是道水题,但找bug找的我想剁手了/(ㄒoㄒ)/~~ 注意几个坑点, 1.输入,getline(cin); / gets(); 一行输入,注意前面要加getchar(); 输入运行记录的时候可 ...
- [Andrew Stankevich's Contest#21] Lempel-Ziv Compression
Time Limit: 20000/10000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Special Judge ...
- ACdream 1214---矩阵连乘
ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...
- ACdream 1429 Rectangular Polygon
Rectangular Polygon Time Limit: 1000MS Memory Limit: 256000KB 64bit IO Format: %lld & %llu D ...
- ACdream 1427 Nice Sequence
主题链接:http://115.28.76.232/problem? pid=1427 Nice Sequence Time Limit: 12000/6000MS (Java/Others)Memo ...
- acdream 1431 Sum vs Product
Sum vs Product Time Limit: 4000/2000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...
随机推荐
- JSP入门:介绍什么是JSP和Servlet(转)
转自:http://developer.51cto.com/art/200907/134506.htm JSP入门:什么是jsp? JSP(Java Server Pages)是由Sun Micros ...
- css文本样式
1. body{ color:aqua; /*可继承的颜色*/ text-align: center; /*文本对齐方式*/ } 2.缩进: index.html <!DOCTYPE html& ...
- CornerStone 破解 最简单的破解方法
方法一:最近在用cornerstone这个svn的软件感觉非常不错,但是竟然忘了破解,以至于到了14天试用期的最后一天才开始破解, 其实方法很简单,就是修高试用期的天数,找到plist文件把14天改为 ...
- 杭州电 1372 Knight Moves(全站搜索模板称号)
http://acm.hdu.edu.cn/showproblem.php?pid=1372 Knight Moves Time Limit: 2000/1000 MS (Java/Others) ...
- Verilog之i2c合约
说明:i2c乔布斯.有这么多的事情在网上参考. 时刻:2014年5一个月6周二星期 1.问题叙述性说明: 正如图.已知的时钟clk为100k,rst为复位信号.上升沿有效,基于Verilog HDL或 ...
- mysql中DES加密解密
DES_DECRYPT(crypt_str[,key_str]) 使用DES_ENCRYPT()加密一个字符串.若出现错误,这个函数会返回 NULL. 注意,这个函数只有当MySQL在SSL 的支 ...
- 输入内容, 列出可选的项: QComboBox
#include "widget.h" #include "ui_widget.h" #include <QtGui/QCompleter> #in ...
- LSI SAS 3008配置操作
配置 LSI SAS 3008 介绍LSISAS3008的配置操作. 4.1 登录CU界面 介绍登录LSISAS3008的CU配置界面的方法. 4.2 创建RAID 介绍在LSISAS3008扣卡上创 ...
- [A Top-Down Approach][第一章 计算机网络和因特网]
[A Top-Down Approach][第一章 计算机网络和因特网] 标签(空格分隔): 计算机网络 介绍基本术语和概念 查看构成网络的基本硬件和软件组件. 从网络的边缘开始,考察在网络中运行的端 ...
- script 表单验证
表单验证:一.非空验证:1.内容是不是空的.判断值的长度是不是0.length属性.压缩空格的函数. 2.内容是不是改变了. 二.对比验证:1.验证两个控件值的关系(相同,大小) 2.验证控件的值与某 ...