8VC Venture Cup 2016 - Elimination Round D. Jerry’s Protest

原创 2016年08月30日 11:23:24
题意:Andrew和Jerry 正在玩一种游戏。他们俩从一个坛子里取一个球,谁的球上的编号大谁获胜。Andrew 赢了第一局和第二局,Jerry 赢了第三局。问Jerry 取的三个球数字总和大于Andrew 的概率是多少 
思路:由于结果是固定的,所以我们只需枚举出所有的胜利方式, 

用a[i]记录胜利方比失败方都i分的概率,sum[i]表示胜利方比失败方多的分数大于等于i的概率。因为i<=5000,所以我们直接暴力枚举就行了

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define L(i) i<<1
#define R(i) i<<1|1
#define INF  0x3f3f3f3f
#define pi acos(-1.0)
#define eps 1e-9
#define maxn 1000100
#define MOD 1000000007

int n,m;
int a[2020];
double p[5050],sum[5050];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t,C = 1;
    //scanf("%d",&t);
    while(scanf("%d",&n) != EOF)
    {
        for(int i = 0; i < n; i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        memset(p,0,sizeof(p));
        for(int i = 0; i < n; i++)
            for(int j = i+1; j < n; j++)
                p[a[j]-a[i]] += 2.0/n/(n-1);
        sum[5010] = 0;
        for(int i = 5009; i > 0; i--)
            sum[i] = sum[i+1] + p[i];
        double ans = 0;
        for(int i = 1; i < 5050; i++)
            for(int j = 1; j < 5050; j++)
        {
            if(i+j > 5010)
                break;
            ans += p[i] * p[j] * sum[i+j+1];
        }
        printf("%.15lf\n",ans);
    }
    return 0;
}


版权声明:随意转载,转载声明出处~

8VC Venture Cup 2016 - Elimination Round E. Simple Skewness(枚举+三分)

题目链接:点击打开链接 题意:给你n个数, 要求选若干个数, 使得这些数的平均数减去中位数尽量大。 思路:由于该题没有顺序问题, 排好序之后我们可以枚举中位数, 可以证明, 奇数个数一定比偶数优,...

8VC Venture Cup 2016 - Elimination Round B. Cards (隐式图DFS)

B. Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

8VC Venture Cup 2016 - Elimination Round-B. Cards(暴力)

B. Cards time limit per test 2 seconds memory limit per test 256 megabytes input s...

8VC Venture Cup 2016 - Elimination Round-C. Block Towers(二分或暴力+数学)

C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes i...

8VC Venture Cup 2016 - Elimination Round-A. Robot Sequence(模拟)

A. Robot Sequence time limit per test 2 seconds memory limit per test 256 megabytes ...

8VC Venture Cup 2016 - Elimination Round A. Robot Sequence

A. Robot Sequence time limit per test 2 seconds memory limit per test 256 megabytes input standar...

8VC Venture Cup 2016 - Elimination Round F. Group Projects(DP)

题目链接:点击打开链接 题意:给n个人, 让我们分成若干组, 每组的值是最大值减去最小值, 求所有组的和。 思路:显然, 需要用DP的思想, 但是该题DP设计的非常巧妙, 而且状态转移的情况容易考...

8VC Venture Cup 2016 - Elimination Round总结

A题: A题题目链接 题目描述: A. Robot Sequence time limit per test 2 seconds memory limit pe...

8VC Venture Cup 2016 - Elimination Round C. Block Towers (二分)

C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

解题报告:8VC Venture Cup 2016 — Elimination Round C.Block Towers

C. Block Towers time limit per test 2 seconds memory limit per test 256 megabytes input standa...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:8VC Venture Cup 2016 - Elimination Round D. Jerry’s Protest
举报原因:
原因补充:

(最多只允许输入30个字)