UVa 11346 Probability

本文探讨了在矩形坐标系中随机选取一点L(X,Y),并计算由原点(0,0)和L定义的矩形面积大于给定值S的概率问题。通过数学推导,给出了一种使用定积分求解该概率的有效方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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%

#include <cstdio>
#include <cmath>

double a, b, s;

int main()
{
	int t;
	scanf("%d", &t);
	int count = 0;
	while(count < t)
	{
		scanf("%lf %lf %lf", &a, &b, &s);
		double result;
		if(s == 0)
			result = 100;
		else if(a*b <= s)
			result = 0;
		else
		{
			result = (a*b-s*log(a)-s+s*log(s/b))/(a*b)*100;	
		}			
		printf("%.6f%%\n", result);
		count++;
	}	
	return 0;
}


题目本身不难,首先明确xy = s为一条双曲线,求得双曲线和矩形相交的上方面积即可。
该面积用定积分来求解,用x积分,被积函数为y, 为b-S/x. 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值