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;
}

  

posted @ 2017-02-10 15:10  Somnuspoppy  阅读(223)  评论(0编辑  收藏  举报