zoukankan      html  css  js  c++  java
  • HDU 3668 Volume (数学,积分)

    题意:求图中交叉圆柱体的体积!

    析:大体思路很明确,把两个圆柱的体积加起来 减去中间公共部分的即可!第一步首先得想到公共部分是一个怎样的图形。这个在高数下册例题中有讲到!

    中间实线部分就是第一卦限内的图形,显然一个二重积分就可以搞定:

    这种情况比较简单点,适合于2*R <= h 的时候!

    如果2*R > h话!

    需要加点想象力,中间公共部分 是一个长方体 加上两个小突起

    也是把他分成8份,只算第一卦限内的。

    把他放到坐标系里 与上一个图相比,没什么变换 只是将上一个图沿x轴平移了h/2 个单位,而0~h/2这片区域是一个长方体!

    这样只需改变积分上下限即可!公式不变!

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <stack>
    using namespace std ;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-10;
    const int maxn = 800 + 5;
    const int mod = 1e9 + 7;
    const char *mark = "+-*";
    const int dr[] = {-1, 0, 1, 0};
    const int dc[] = {0, 1, 0, -1};
    int n, m;
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    
    int main(){
        double r,h;
        while(scanf("%lf %lf",&r,&h) == 2){
            if (2*r > h + eps){
                double a = sqrt(r*r-h*h/4);
                double V = 2*PI*r*r*h;
                double other = h*h*a/4 + r*r*r*2/3  + (a)*(a)*(a)/3 - r*r*a;
                double ans = V-8.0*other;
                printf("%.4lf
    ",ans+eps);
    
            }else{
                double V = 2*PI*r*r*h;
                double other = 8*2*r*r*r/3;
                double ans = V-other;
                printf("%.4lf
    ",ans+eps);
            }
        }
    
        return 0;
    }
    

      

  • 相关阅读:
    BZOJ1257:[CQOI2007]余数之和——题解+证明
    BZOJ3781:小B的询问——题解
    BZOJ2038:[2009国家集训队]小Z的袜子——题解
    BZOJ3052 & UOJ58:[WC2013]糖果公园——题解
    BZOJ1086:[SCOI2005]王室联邦——题解
    BZOJ1878:[SDOI2009]HH的项链——题解
    BZOJ2453:维护队列——题解
    美团新零售招聘-高级测试开发(20k-50k/月)
    Shopee招聘-测试开发leader(30k-60k/月)
    蚂蚁金服招聘-无线测试开发(20k-36k/月)
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5783721.html
Copyright © 2011-2022 走看看