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

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

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<string>
  5. #include<vector>
  6. #include<queue>
  7. #include<algorithm>
  8. #include<iostream>
  9. using namespace std;
  10.  
  11. const int maxn = + ;
  12. int n;
  13. int a[maxn];
  14. int b[maxn];
  15. int sum[maxn];
  16.  
  17. int main()
  18. {
  19. scanf("%d", &n);
  20. for (int i = ; i <= n; i++) scanf("%d", &a[i]);
  21. memset(sum, , sizeof sum);
  22. memset(b, , sizeof b);
  23. sort(a+, a + n+);
  24. for (int i = ; i <= n; i++)
  25. for (int j = i + ; j <= n; j++)
  26. b[a[j] - a[i]]++;
  27.  
  28. double ans = ;
  29.  
  30. for (int i = ; i <= ; i++) sum[i] = sum[i - ] + b[i];
  31.  
  32. for (int i = ; i <= ; i++)
  33. for (int j = ; j <= ; j++)
  34. {
  35. if (i + j <= )
  36. ans = ans + 1.0*b[i] * b[j] * (sum[] - sum[i + j]);
  37. }
  38.  
  39. // printf("%d\n", ans);
  40. double N = (double)n;
  41. double f = N*(N - )*N*(N - )*N*(N - ) / 8.0;
  42. printf("%.6lf\n", 1.0*ans / f);
  43. return ;
  44. }

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. mapreduce 顺序组合

    import java.io.IOException;import java.util.StringTokenizer; import org.apache.hadoop.conf.Configura ...

  2. CDN(转载)

    CDN是什么? 谈到CDN的作用,可以用8年买火车票的经历来形象比喻: 8年前,还没有火车票代售点一说,12306.cn更是无从说起.那时候火车票还只能在火车站的售票大厅购买,而我所住的小县城并不通火 ...

  3. C++:预处理指令

    Preprocessor directives 预处理器指令 预处理器指令是指那些包含在我们代码中的预处理器语句行,这些预处理器语句不是真正的代码语句,但是他们指导程序如何进行编译.这些语句总是以 ‘ ...

  4. 6-SUPER关键字

    (1)强行调用父类方法的执行(2)super不一定在重写中使用,也可以表示那些方法是从父类中继承而来的.

  5. 【使用Itext处理PDF文档(新建PDF文件、修改PDF文件、PDF中插入图片、将PDF文件转换为图片)】

    iText简介 iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成PDF或rtf的文档,而且可以将XML.Html文件转 ...

  6. Cannot call sendRedirect() after the response has been committed

    AJAX+JSP时,out.write('content')之后,如果后面还有代码,无法被执行到,会报 错,java.lang.IllegalStateException: Cannot call s ...

  7. linux logrotate配置

    对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以使用logrotate 程序用来管理系统中的最新的事件,对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以 ...

  8. java sni support result in svn fail

    svn: E175002: handshake alert:  unrecognized_name http://stackoverflow.com/questions/7615645/ssl-han ...

  9. STM32软件复位(基于库文件V3.5)

    源:STM32软件复位(基于库文件V3.5) void SoftReset(void) { __set_FAULTMASK(); // 关闭所有中端 NVIC_SystemReset();// 复位 ...

  10. zf-关于荆州图片链接和弹出页面问题

    target="_blank" 属性不能写在div 里 所以我在里面加了个a标签 这个属性的作用就是弹出一个新的页面,不会在原先的页面上换地址 如果 style 的加载图片卸载cs ...