UVA - 11346 Probability (概率)

Description

G - Probability

Time Limit: 1 sec

Memory Limit: 16MB

Consider rectangular coordinate system and point L(X,Y) which is randomly chosen among all points in the area A which is defined in the following manner: A = {(x,y) | x is from interval [-a;a]; y is from interval [-b;b]}. What is the probability P that the
area of a rectangle that is defined by points (0,0) and (X,Y) will be greater than S?

INPUT:

The number of tests N <= 200 is given on the first line of input. Then N lines with one test case on each line follow. The test consists of 3 real numbers a > 0, b > 0 ir S => 0.

OUTPUT:

For each test case you should output one number P and percentage " %" symbol following that number on a single line. P must be rounded to 6 digits after decimal point.

SAMPLE INPUT:

3
10 5 20
1 1 1
2 2 0

SAMPLE OUTPUT:

 23.348371%
0.000000%
100.000000%
题意:给定a,b,s要求在[-a,a]选定x,在[-b,b]选定y,使得(0, 0)和(x, y)组成的矩形面积大于s的概率
思路:转换成x*y > s的图形面积,利用求导函数求面积的方式计算,y=s/x的导函数是y=s*lnx

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int t;
	double a, b, s;
	scanf("%d", &t);
	while (t--) {
		scanf("%lf%lf%lf", &a, &b, &s);
		if (a * b <= s) {
			puts("0.000000%");
			continue;
		}
		if (s == 0) {
			puts("100.000000%");
			continue;
		}
		printf("%lf%%\n", 100 - (s + s * (log(a) - log(s / b))) / a / b * 100);
	}
	return 0;
}

时间: 2024-11-02 21:32:31

UVA - 11346 Probability (概率)的相关文章

UVA 11346 - Probability(概率)

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

uva 11346 - Probability(可能性)

题目链接: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&g

UVa 11346 Probability (转化+积分+概率)

题意:给定a,b,s,在[-a, a]*[-b, b]区域内任取一点p,求以原点(0,0)和p为对角线的长方形面积大于s的概率. 析:应该明白,这个和高中数学的东西差不多,基本就是一个求概率的题,只不过更简单了,不用你算了,你给出表达式, 让计算机帮你算即可. 由对称性知道,只要求[a, b]区域内的概率就OK了,也就是xy > s,由高中的知识也知道应该先求xy = s的曲线, 然后求在曲线上面的面积,这就用到了积分,由于上面的不好求,我们先求下面的,再用总面积减掉即可(自己画个图看看), 挺

UVA 11346 - Probability 数学积分

Consider rectangular coordinate system and point L(X, Y ) which is randomly chosen among all pointsin the area A which is de?ned in the following manner: A = {(x, y)|x ∈ [−a; a];y ∈ [−b; b]}. What isthe probability P that the area of a rectangle that

UVA 11346 Probability (几何概型, 积分)

题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=2321">https://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&page=show_problem&problem=2321 题目大意:在A是一个点集 A = {(x, y) | x ∈[-a, a],y∈[-b, b]},求取出

Uva 11346 Probability 积分

化成反比函数求积分 G - Probability Time Limit: 1 sec Memory Limit: 16MB Consider rectangular coordinate system and point L(X,Y) which is randomly chosen among all points in the area A which is defined in the following manner: A = {(x,y) | x is from interval [

●UVa 11346 Probability

题链: https://vjudge.net/problem/UVA-11346题解: 连续概率,积分 由于对称性,我们只用考虑第一象限即可. 如果要使得面积大于S,即xy>S, 那么可以选取的点必须在双曲线xy=S的第一象限那一支的左上方. 也就是要求左下角在原点,长宽分别为a,b的矩形与双曲线的一支围成的面积. 所以由积分可得:我们要求的面积$$S'=a×b-S-S×\int_{S/b}^{a}\frac{1}{x}dx$$ 因为$y=\frac{1}{x}$的原函数为$y=ln(x)$ 所

uva 11181 - Probability|Given

条件概率公式:P( A|B ) = P( AB ) / P( B ) 表示在事件B发生的前提下,事件A发生的概率: 对本道题: 设事件E:r个人买了东西: 事件Ei:第i个人买了东西: 则要求的是P( Ei | E ); 计算P( E ) 用全概率公式即可,采用递归枚举出所有r个人买东西的情况,然后计算出其总的概率: 计算P( Ei ) 就是在上面递归枚举的过程中将选上第i个人的情况的概率加起来:(在这种情况下,其概率就是:在E发生的前提下的概率) 代码: #include<cstdio> #

概率论 --- Uva 11181 Probability|Given

Uva 11181 Probability|Given Problem's Link:   http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18546 Mean: n个人去逛超市,第i个人会购买东西的概率是Pi.出超市以后发现有r个人买了东西,问你每个人购买东西的实际概率是多少. analyse: 转换模型: 有n个员工,每个员工被选出来的概率是Pi.最后选出了r个,问你第i个员工在这r个中的概率是多少. 设: 事件A---