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 ...
随机推荐
- mapreduce 顺序组合
import java.io.IOException;import java.util.StringTokenizer; import org.apache.hadoop.conf.Configura ...
- CDN(转载)
CDN是什么? 谈到CDN的作用,可以用8年买火车票的经历来形象比喻: 8年前,还没有火车票代售点一说,12306.cn更是无从说起.那时候火车票还只能在火车站的售票大厅购买,而我所住的小县城并不通火 ...
- C++:预处理指令
Preprocessor directives 预处理器指令 预处理器指令是指那些包含在我们代码中的预处理器语句行,这些预处理器语句不是真正的代码语句,但是他们指导程序如何进行编译.这些语句总是以 ‘ ...
- 6-SUPER关键字
(1)强行调用父类方法的执行(2)super不一定在重写中使用,也可以表示那些方法是从父类中继承而来的.
- 【使用Itext处理PDF文档(新建PDF文件、修改PDF文件、PDF中插入图片、将PDF文件转换为图片)】
iText简介 iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成PDF或rtf的文档,而且可以将XML.Html文件转 ...
- Cannot call sendRedirect() after the response has been committed
AJAX+JSP时,out.write('content')之后,如果后面还有代码,无法被执行到,会报 错,java.lang.IllegalStateException: Cannot call s ...
- linux logrotate配置
对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以使用logrotate 程序用来管理系统中的最新的事件,对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以 ...
- java sni support result in svn fail
svn: E175002: handshake alert: unrecognized_name http://stackoverflow.com/questions/7615645/ssl-han ...
- STM32软件复位(基于库文件V3.5)
源:STM32软件复位(基于库文件V3.5) void SoftReset(void) { __set_FAULTMASK(); // 关闭所有中端 NVIC_SystemReset();// 复位 ...
- zf-关于荆州图片链接和弹出页面问题
target="_blank" 属性不能写在div 里 所以我在里面加了个a标签 这个属性的作用就是弹出一个新的页面,不会在原先的页面上换地址 如果 style 的加载图片卸载cs ...