计算前两盘A赢,最后一盘B赢的情况下,B获得的球的值总和大于A获得的球总和值的概率。

存储每一对球的差值有几个,然后处理一下前缀和,暴力枚举就好了......

#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<iostream>
using namespace std; const int maxn = + ;
int n;
int a[maxn];
int b[maxn];
int sum[maxn]; int main()
{
scanf("%d", &n);
for (int i = ; i <= n; i++) scanf("%d", &a[i]);
memset(sum, , sizeof sum);
memset(b, , sizeof b);
sort(a+, a + n+);
for (int i = ; i <= n; i++)
for (int j = i + ; j <= n; j++)
b[a[j] - a[i]]++; double ans = ; for (int i = ; i <= ; i++) sum[i] = sum[i - ] + b[i]; for (int i = ; i <= ; i++)
for (int j = ; j <= ; j++)
{
if (i + j <= )
ans = ans + 1.0*b[i] * b[j] * (sum[] - sum[i + j]);
} // printf("%d\n", ans);
double N = (double)n;
double f = N*(N - )*N*(N - )*N*(N - ) / 8.0;
printf("%.6lf\n", 1.0*ans / f);
return ;
}

CodeForces 626D Jerry's Protest的更多相关文章

  1. Codeforces 626D Jerry's Protest(暴力枚举+概率)

    D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  2. Codeforces 626D Jerry's Protest 「数学组合」「数学概率」

    题意: 一个袋子里装了n个球,每个球都有编号.甲乙二人从每次随机得从袋子里不放回的取出一个球,如果甲取出的球比乙取出的球编号大则甲胜,否则乙胜.保证球的编号xi各不相同.每轮比赛完了之后把取出的两球放 ...

  3. 8VC Venture Cup 2016 - Elimination Round D. Jerry's Protest 暴力

    D. Jerry's Protest 题目连接: http://www.codeforces.com/contest/626/problem/D Description Andrew and Jerr ...

  4. 数学(概率)CodeForces 626D:Jerry's Protest

    Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...

  5. codeforces626D . Jerry's Protest (概率)

    Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...

  6. codeforces626D . Jerry's Protest

    Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...

  7. 8VC Venture Cup 2016 - Elimination Round

    在家补补题   模拟 A - Robot Sequence #include <bits/stdc++.h> char str[202]; void move(int &x, in ...

  8. codeforce626D (概率)

    D. Jerry's Protest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces 718A Efim and Strange Grade 程序分析

    Codeforces 718A Efim and Strange Grade 程序分析 jerry的程序 using namespace std; typedef long long ll; stri ...

随机推荐

  1. 【裸最小生成树】 模板 poj 1258

    #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #def ...

  2. php并发控制 , 乐观锁

    由于悲观锁在开始读取时即开始锁定,因此在并发访问较大的情况下性能会变差.对MySQL Inodb来说,通过指定明确主键方式查找数据会单行锁定,而查询范围操作或者非主键操作将会锁表. 接下来,我们看一下 ...

  3. Zookeeper: configuring on centos7

    thispassage is referenced, appreciated. ZooKeeper installation: Download from this site Install java ...

  4. Slow HTTP Denial of Service Attack 漏洞解决

    修改tomcat conf 下  server.xml 文件 <Connector port="8080" protocol="HTTP/1.1" con ...

  5. Category / Extention / 属性 / 成员变量 /

    转载自:http://blog.csdn.net/itianyi/article/details/8618128 在ios第一版中,我们为输出口同时声明了属性和底层实例变量,那时,属性是oc语言的一个 ...

  6. python顶级执行代码

    只有主程序中由大量顶级执行代码(即没有被缩进的代码行),所有其他被导入的模块只应该又很少的顶级执行代码. 如果模块是被导入,__name__就是模块名. 如果模块是被直接执行,__name__就是__ ...

  7. oracle10g遇到ORA-00257归档程序错误,在释放之前仅限于内部连接

    一.简要介绍 首先数据库日志文件有两种: 联机日志文件和归档日志文件,联机日志文件会将之前的覆盖,不会做备份. 而归档日志文件会做备份,这样就造成了归档日志空间已满,解决方法: 如果真的是归档日志空间 ...

  8. POJ 2773 Happy 2006(欧几里德算法)

    题意:给出一个数m,让我们找到第k个与m互质的数. 方法:这题有两种方法,一种是欧拉函数+容斥原理,但代码量较大,另一种办法是欧几里德算法,比较容易理解,但是效率很低. 我这里使用欧几里德算法,欧几里 ...

  9. 二分图最大匹配 Hopcroft-Karp算法模板

    #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> ...

  10. CST 公共生成树

    本实验只讨论CST(公共的生成树) 一.实验前先理解生成树决策的4 个步骤: 二.实验拓扑 1. 实验描述: 由于业务的要求,要有可靠的链路,要对链路实现冗余,但链路的冗余有可能给网络带来广播风暴,重 ...