您的位置:首页 > 其它

UVA 11346 - Probability(概率)

2014-07-17 18:37 441 查看


UVA 11346 - Probability

题目链接

题意:给定a,b,s要求在[-a,a]选定x,在[-b,b]选定y,使得(0, 0)和(x, y)组成的矩形面积大于s,求概率

思路:这样其实就是求xy > s的概率,那么画出图形,只要求y = s / x的原函数, y = slnx,带入两点相减就能求出面积,面积比去总面积就是概率

代码:

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

int t;
double a, b, s;

int main() {
scanf("%d", &t);
while (t--) {
scanf("%lf%lf%lf", &a, &b, &s);
if (s == 0) printf("100.000000%%\n");
else if (s >= a * b) printf("0.000000%%\n");
else printf("%.6lf%%\n", (a * b - s - s * (log(a) - log(s/b))) / (a * b) * 100);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: