uva 11346

题目链接:uva 11346 - Probability

题目大意:给定x,y的范围。以及s,问说在该范围内选取一点,和x,y轴形成图形的面积大于s的概率。

解题思路:首先达到方程xy ≥ s。即y = s / x。


S2的面积用积分计算,y = s / x的原函数为lnx
所以
S2=s(ln(a)ln(x))

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main  () {
    int cas;
    double a, b, s;
    scanf("%d", &cas);

    while (cas--) {
        scanf("%lf%lf%lf", &a, &b, &s);
        double r = min(s / b, a);
        double ans = r * b + log(a) * s;

        if (fabs(s) > 1e-9)
            ans = ans - log(r) * s;

        double p = 1 - ans / (a * b);
        printf("%.6lf%c
",  fabs(p * 100), '%');
    }
    return 0;
}
原文地址:https://www.cnblogs.com/gcczhongduan/p/4586660.html