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 ...
随机推荐
- 让iframe调用页面的背景透明
需求:在一个div里面嵌套一个iframe(src="ui.html"),div有背景图片,要让iframe里的内容透明地显示在div层上. 刚开始直接把iframe放在div中, ...
- 查看db2表空间使用率
select char(TABLESPACE_NAME,16) tablespace_name,decimal(PAGE_SIZE/1024,4,2) page,used_pages*100/usab ...
- Java编程思想-第四章练习题
练习1:写一个程序,打印从1到100的值 public class Print1To100{ public static void main(String args[]){ for(int i = 1 ...
- Linux下的bc计算器
bc = basic calculator scale:设置精度,默认为0 obase:设置输出进制,默认为10 ibase:设置输入进制,默认为10 原文:http://www.linuxidc.c ...
- jTemplates——学习(1)
这里介绍一个基于jQuery开发的模板引擎. jTemplates目前最新的版本是0.7.8,由tPython开发.官方网站:http://jtemplates.tpython.com 两个附件, 一 ...
- mac显示隐藏文件夹
~/Library/Preferences/com.apple.finder AppleShowAllFiles -bool true (true 改成 false 就可以不再显示隐藏文件)需要重启, ...
- IOS-连接
http://blog.sina.com.cn/s/articlelist_2659739627_0_2.html
- 图形绘制 Canvas Paint Path 详解
图形绘制简介 Android中使用图形处理引擎,2D部分是android SDK内部自己提供,3D部分是用Open GL ES 1.0.大部分2D使用的api都在android.grap ...
- 输入框提示--------百度IFE前端task2
第一版本: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- python比较两个列表
两个列表,随机产生4个不相等的数,计算一下,相同位置上的元素相等的个数,用k1表示. b列表中的元素在a列表中,但位置不相同,有多少个,用k2表示. 例如: a=[0, 4, 7, 3]b=[7, 1 ...