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]},求取出的点和(0, 0)构成的矩形面积大于S的概率

题目分析:由对称性,考虑第一象限就可以,最好还是先设xy = S。得到反比例函数y = S / x,先求小于S的概率,就是反比例函数与边界以及x轴y轴围成的面积,这部分面积分为两块,一块是高为b,宽为min(s / b, a)的矩形,还有一块须要积分,只是y = S / x这个积分也太简单Y = S*ln(x)。区间就是min(s / b, a)到a,然后用a * b减去那两块面积和就是第一象限中选点大于S的概率。一開始要特判一下100%的情况,不然会变成无穷大

#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
double const EPS = 1e-10;

int main()
{
    int T;
    scanf("%d", &T);
    while(T --)
    {
        double a, b, s;
        scanf("%lf %lf %lf", &a, &b, &s);
        if(s - 0 < EPS)
        {
            printf("100.000000%%\n");
            continue;
        }
        double x1 = min(s / b, a);
        double s1 = b * x1 + s * log(a / x1);
        double s2 = a * b - s1;
        double sum = a * b;
        double part = s2;
        double ans = part / sum * 100.0;
        printf("%.6f%%\n", fabs(ans));
    }
}
时间: 2024-10-21 09:25:06

UVA 11346 Probability (几何概型, 积分)的相关文章

UVA 11971 - Polygon(概率+几何概型)

UVA 11971 - Polygon 题目链接 题意:给一条长为n的线段,要选k个点,分成k + 1段,问这k + 1段能组成k + 1边形的概率 思路:对于n边形而言,n - 1条边的和要大于另外那条边,然后先考虑3边和4边形的情况,根据公式在坐标系中画出来的图,总面积为x,而不满足的面积被分成几块,每块面积为x/2k,然后在观察发现一共是k + 1块,所以符合的面积为x?x?(k+1)/2k,这样一来除以总面积就得到了概率1?(k+1)/2k 代码: #include <cstdio>

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 数学积分

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 积分

化成反比函数求积分 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 (转化+积分+概率)

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

集训第六周 数学概念与方法 UVA 11722 几何概型

---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[s1,s2]的时间段停留在同一个站点w分钟,问两辆火车能够在这个站点相遇的概率. 思路,枚举每一种情况,把两辆火车的相交区间画出来,然后求都在这个区间的概率 #include"iostream" #include"cstdio" #include"cmath&

数学概念——A 几何概型

You are going from Dhaka to Chittagong by train and you came to know one of your old friends is going from city Chittagong to Sylhet. You also know that both the trains will have a stoppage at junction Akhaura at almost same time. You wanted to see y

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