设为首页 加入收藏

TOP

acdream 1234 Two Cylinders
2015-07-20 17:32:54 来源: 作者: 【 】 浏览:2
Tags:acdream 1234 Two Cylinders

Two Cylinders

Special JudgeTime Limit: 10000/5000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) SubmitStatisticNext Problem

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

Input file contains two real numbers R1 and R2 (1 <= R1,R2 <= 100).

Output

Output the volume of the intersection of the cylinders. Your answer must be accurate up to 10-4.

Sample Input

1 1

Sample Output

5.3333

Source

Andrew Stankevich Contest 3

Manager

mathlover


题解及代码:

这道题的意思很简单,就是求两个垂直相交的圆柱的重合体积。推导的思想可以见:点击打开链接

根据上面的方法我们可以推出截面公式是sqrt(R*R-x*x)*sqrt(r*r-x*x),然后积分的上下限是0--r。

虽然这公式推出来了,但是积分很困难(没推出来= =!),下面的代码用的是辛普森积分法,学习了一下,挺简单的。

主要就是这个:vc/QobXEyrG68qOszvOy7rK7tPOjrLWrysfK/bHIvc+087XEyrG68qOszvOy7r7Nuty088HLo6zL+dLUvMbL47n9s8zW0NKqyrnTw7b+t9bAtLDRx/i85Lz10KGjrLz10KHO87LuoaM8L3A+CjxwPjxicj4KPC9wPgo8cD48cHJlIGNsYXNzPQ=="brush:java;">#include #include #include using namespace std; const double eps=1e-7; double R,r; double f(double n) { return 8*sqrt(R*R-n*n)*sqrt(r*r-n*n); } double simpson(double a,double b) { return (b-a)/6.0*(f(a)+4*f((a+b)/2.0)+f(b)); } double cal(double a,double b) { double sum=simpson(a,b),mid=(a+b)/2.0; double t=simpson(a,mid)+simpson(mid,b); if(fabs(t-sum)



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Path Sum 下一篇poj 3414 Pots (bfs+路径记录)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)
·[ Linux运维学习 ] (2025-12-26 02:52:27)
·HTTPS 详解一:附带 (2025-12-26 02:20:37)
·TCP/IP协议到底在讲 (2025-12-26 02:20:34)