很简单的一道题目。
先把研究总空间缩小到第一象限,这样表达式就可以写成xy > s ,会发现是以反函数,求出两个端点,用定积分求面积即可,
需要主要的是a,b,s都是实数,当s >= a*b-eps就是0%
当s < eps 等于0时,就是100%!
代码如下:
#include<cmath>
#include<iostream>
#include<cstdio>
using namespace std;
const double eps = 1e-8;
int main()
{
//ios::sync_with_stdio(false);
//freopen("out.txt","w",stdout);
int n;
cin >> n;
for (int i = 0; i < n; ++i){
double a,b,s;
cin >> a >> b >> s;
if (s >= a*b - eps){
cout << "0.000000%" << endl;
continue;
}
if (s < eps){
cout << "100.000000%" << endl;
continue;
}
double prob = (a * b - s * (log(a)-log(s/b) + 1)) * 100.0 / (a * b);
printf("%.6lf%%\n",prob);
}
return 0;
}