Probability Through Experiments

题目链接

  • 题意:

    给n个在圆上的点,和圆的半径,每个点给出和x轴正方向的夹角,求能构成的锐角三角形的个数。

  • 分析:

    锐角不好求,对于钝角和直角是比较好求的:直角就是有一个边过圆心;钝角就是三个边均在圆心的一侧

  • 重点:

    这个题目很重要的一点就是精度问题,题目的输入是三位小数,但是直接用double做没办法AC。。。改用乘以1000后取整也无法AC,需要注意精度处理

const int MAXN = 41000;

int ipt[MAXN];

int main()
{
    LL n, r;
    int kase = 1;
    while (cin >> n >> r && (n && r))
    {
        REP(i, n)
        {
            int a, b;
            scanf("%d.%d", &a, &b);
            ipt[i] = a * 1000 + b;
        }
        sort(ipt, ipt + n);
        FF(i, n, n + n)
            ipt[i] = ipt[i - n] + 360000;
        LL ans = 0, idx, x;
        LL all = n * (n - 1) * (n - 2) / 6;
        REP(i, n)
        {
            idx = lower_bound(ipt + i, ipt + n + i, ipt[i] + 180000) - ipt;
            x = n + i - idx;
            if (x >= 2)
                ans += (x - 1) * x / 2;
        }
        cout << "Case " << kase++ << ": " << all - ans << endl;
    }
    return 0;
}

Probability Through Experiments

时间: 2024-07-29 14:29:08

Probability Through Experiments的相关文章

Fuzzy Probability Theory---(3)Discrete Random Variables

We start with the fuzzy binomial. Then we discuss the fuzzy Poisson probability mass function. Fuzzy Binomial Let $E$ be a non-empty, proper subset of $X=\{x_1,x_2,x_3,...,x_n\}$. Let $P(E)=p$ so that $P(E^{'})=1-p$ where $p\in (0,1)$. Suppose we hav

Tensorflow word2vec+manage experiments

Lecture note 5: word2vec + manage experiments Word2vec Most of you are probably already familiar with word embedding and understand the importance of a model like word2vec. For those who aren't, Stanford CS 224N's lecture on word vectors is a great r

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

Introduction to Probability (5) Continus random variable

CONTINUOUS RANDOM VARIABLES AND PDFS  连续的随机变量,顾名思义.就是随机变量的取值范围是连续的值,比如汽车的速度.气温.假设我们要利用这些參数来建模.那么就须要引入连续随机变量. 假设随机变量X是连续的,那么它的概率分布函数能够用一个连续的非负函数来表示,这个非负函数称作连续随机变量的概率密度函数(probability density function).并且满足: 假设B是一个连续的区间,那么: watermark/2/text/aHR0cDovL2Js

HDU2131 Probability【水题】

Probability Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5205    Accepted Submission(s): 2597 Problem Description Mickey is interested in probability recently. One day , he played a game whi

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 [

基本概率分布Basic Concept of Probability Distributions 4: Negative Binomial Distribution

PDF version PMF Suppose there is a sequence of independent Bernoulli trials, each trial having two potential outcomes called "success" and "failure". In each trial the probability of success is $p$ and of failure is $(1-p)$. We are obs

基本概率分布Basic Concept of Probability Distributions 2: Poisson Distribution

PDF version PMF A discrete random variable $X$ is said to have a Poisson distribution with parameter $\lambda > 0$, if the probability mass function of $X$ is given by $$f(x; \lambda) = \Pr(X=x) = e^{-\lambda}{\lambda^x\over x!}$$ for $x=0, 1, 2, \cd