zoukankan      html  css  js  c++  java
  • UVA 11346 Probability(概率)(连续概率)

    题意:在[-a, a]*[-b, b]区域内随机取一个点P,求以(0, 0)和P为对角线的长方形面积大于S的概率(a,b>0, S>=0)。

    分析:

    1、若长方形面积>S,则选取的P(x,y)满足xy>S,xy=S是双曲线,P取双曲线上方,[-a, a]*[-b, b]区域内的某点则满足条件。

    2、(双曲线上方,[-a, a]*[-b, b]区域内)这块区域的面积w/(a*b)则为答案。

    3、面积w求法:ab - 双曲线下方面积(S + S*ln(a*b/S))。

    #pragma comment(linker, "/STACK:102400000, 102400000")
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define Min(a, b) ((a < b) ? a : b)
    #define Max(a, b) ((a < b) ? b : a)
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 10000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    int main(){
        int T;
        scanf("%d", &T);
        while(T--){
            double a, b, S;
            scanf("%lf%lf%lf", &a, &b, &S);
            double m = a * b;
            if(S >= a * b){
                printf("0.000000%%\n");
                continue;
            }
            if(fabs(S) < eps){
                printf("100.000000%%\n");
                continue;
            }
            double ans = (m - S - S * log(m / S)) * 100 / m;
            printf("%.6lf%%\n", ans);
        }
        return 0;
    }
    

      

  • 相关阅读:
    图的深度优先遍历(邻接表,递归,非递归)
    图的深度优先遍历(邻接矩阵,递归,非递归)
    【转】C语言邻接表的实现
    图的存储
    堆排序_C实现
    快排_C实现
    交换二叉树中所有结点的左右子树的位置
    二叉树层次遍历_判断结点所属层次
    二叉树_非递归先中后序_递归非递归求深度
    二叉树非递归遍历(前、中、后)
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/6386427.html
Copyright © 2011-2022 走看看