程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> BestCoder Round #12 War(計算幾何)

BestCoder Round #12 War(計算幾何)

編輯:C++入門知識

BestCoder Round #12 War(計算幾何)


War

Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 81 Accepted Submission(s): 23
Special Judge


Problem Description Long long ago there are two countrys in the universe. Each country haves its own manor in 3-dimension space. Country A's manor occupys x^2+y^2+z^2<=R^2. Country B's manor occupys x^2+y^2<=HR^2 && |z|<=HZ. There may be a war between them. The occurrence of a war have a certain probability.
We calculate the probability as follow steps.
1. VC=volume of insection manor of A and B.
2. VU=volume of union manor of A and B.
3. probability=VC/VU
Input Multi test cases(about 1000000). Each case contain one line. The first line contains three integers R,HR,HZ. Process to end of file.

[Technical Specification]
0< R,HR,HZ<=100

Output For each case,output the probability of the war which happens between A and B. The answer should accurate to six decimal places.
Sample Input
1 1 1
2 1 1

Sample Output
0.666667
0.187500

Source BestCoder Round #12
Recommend heyang | We have carefully selected several similar problems for you: 5061 5059 5058 5053 5052 題意: 給你一個球心在原點.半徑為r的球和一個圓柱體。圓柱體半徑為hr,高為hz然後通徑為z軸.然後通徑中點也在原點。 然後問你相交部分的體積vc/體積並vu。 思路: 這題由於原點中點都在原點所以比較好做。一前還沒怎麼寫過計算幾何的題,由於最後一題不會。只有硬著頭皮上了。我們就分類討論。r,和hr的大小。然後在討論下圓柱體有沒有穿出球體。即sqrt(r*r-hr*hr)和r的大小。對於一部分的球體的體積用用定積分.積出來為PI*r*r*z-PI*z*z*z/3|上下限。 詳細見代碼:
#include
#include
#include
#include
#include
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=100010;
const double PI=acos(-1.0);
const double eps=1e-8;
typedef long long ll;

int main()
{
    double r,hr,hz,vc,vu,d,a,b,hh;

    while(~scanf("%lf%lf%lf",&r,&hr,&hz))
    {
        if(hr

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved