CodeForces 626D Jerry's Protest
计算前两盘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的更多相关文章
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces 626D Jerry's Protest 「数学组合」「数学概率」
题意: 一个袋子里装了n个球,每个球都有编号.甲乙二人从每次随机得从袋子里不放回的取出一个球,如果甲取出的球比乙取出的球编号大则甲胜,否则乙胜.保证球的编号xi各不相同.每轮比赛完了之后把取出的两球放 ...
- 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 ...
- 数学(概率)CodeForces 626D:Jerry's Protest
Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...
- codeforces626D . Jerry's Protest (概率)
Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...
- codeforces626D . Jerry's Protest
Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...
- 8VC Venture Cup 2016 - Elimination Round
在家补补题 模拟 A - Robot Sequence #include <bits/stdc++.h> char str[202]; void move(int &x, in ...
- codeforce626D (概率)
D. Jerry's Protest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 718A Efim and Strange Grade 程序分析
Codeforces 718A Efim and Strange Grade 程序分析 jerry的程序 using namespace std; typedef long long ll; stri ...
随机推荐
- %3f URL --> '?'拼接引发的问题
转载自:https://www.reddit.com/r/swift/comments/2w19kp/how_do_you_send_a_through_nsmutableurlrequest/ ho ...
- python 中调用shell命令
subprocess模块 根据Python官方文档说明,subprocess模块用于取代上面这些模块.有一个用Python实现的并行ssh工具—mssh,代码很简短,不过很有意思,它在线程中调用sub ...
- display:block;inline;inline-block大总结
总体概念 block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素).block元素通 ...
- Amoeba for MySQL
Amoeba for MySQL Amoeba for MySQL致力于MySQL的分布式数据库前端代理层,它主要在应用层访问MySQL的时候充当query 路由功能,专注 分布式数据库 proxy ...
- HDU 2475 BOX 动态树 Link-Cut Tree
Box Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Problem De ...
- BootStrap详解之(二)
六.内容 Bootstrap 将全局 font-size 设置为 14px,line-height 设置为 1.428 中心内容 .lead 将字体大小.加粗.行高修改 (无卵高深用) 标记 mark ...
- 项目中常用js方法整理common.js
抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...
- php获取Linux网卡信息
$data = exec("/sbin/ifconfig"); var_dump($data); 注意:有时候这种方式获取不到,应该是权限问题 在/var/rootP文件中添加ro ...
- Excel相关问题
Excel默认永远使用最后安装的那个Excel版本打开.但是如果有一个Excel已经启动了,则使用那个Excel打开. 1.打开“开发工具”选项卡2007中:[Excel选项]-[常用]2010中:[ ...
- ubuntu ssh重启
SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-g ...