题意:n个人参加一个游戏,每个人选择0-100范围的数。m为选择的所有数的平均数*2/3,选择的数<=m且距离m最近的人获胜,若同时有多人满足条件则随机抽取胜者。如果一个人选的数,比m小,且相距m最为接近,那么其便在所有选数相同的人中等概率中奖。已知n-1个人的数,输出一个你选择的最大的数和最大胜率。

思路:设我选择的数为x,n-1个数的总和为sum,应满足x<=(sum+x)/n*2/3 ,即 x<=2sum/(3n-2)。

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cstring>
  4. using namespace std;
  5. int num[];
  6. int main() {
  7. int n,t,x;
  8. double sum,temp;
  9. scanf("%d",&t);
  10. while(t--) {
  11. memset(num,,sizeof num);
  12. scanf("%d",&n);
  13. sum=;
  14. for(int i=;i<n-;i++) {
  15. scanf("%d",&x);
  16. num[x]++;
  17. sum+=x;
  18. }
  19. int res=2.0*sum/(3.0*n-);
  20. double pro=1.0/(num[res]+);
  21. printf("%d %.2f\n",res,pro);
  22. }
  23. return ;
  24. }

HDU 5704的更多相关文章

  1. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...

  2. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  4. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  5. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  6. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  8. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  9. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

随机推荐

  1. JDBC批量操作性能提升

    JDBC 当使用INSERT INTO....VALUES()语句批量插入的时候,应该使用JDBC的PreparedStatement的批量操作方法,而不是採用一条一条运行的方法. 比如(来源:htt ...

  2. Eclipse中JSP页面默认编码修改

    jsp页面默认编码为ISO-8859-1 要修改为UTF-8,步骤如下 选择windon-->preference 在弹出框操作 以后新建jsp页面编码为UTF-8编码

  3. python序列中添加高斯噪声

    def wgn(x, snr): snr = 10**(snr/10.0) xpower = np.sum(x**2)/len(x) npower = xpower / snr return np.r ...

  4. Powershell计算时间间隔(New-TimeSpan)

    在Windows PowerShell里New-TimeSpan cmdlet提供了一种方法做日期算法. 计算时间间隔: 这个命令告诉你今天的日期与2006年除夕之间的天数: New-TimeSpan ...

  5. Audit logon events&Logon type

    表一.Logon type 表二.Audit logon events 表三.Logon type details Logon type Logon title Description 2 Inter ...

  6. druid

    实时分析型数据库 Druid | Interactive Analytics at Scale http://druid.io/ Druid is primarily used to store, q ...

  7. Oracle 11g修改字符集AL32UTF8为ZHS16GBK

    oracle11g更改字符集AL32UTF8为ZHS16GBK当初安装oracle的时候选择的默认安装,结果字符集不是以前经常用的16GBK,要改字符集,从网上找到了方法并试了一下,果然好用! 具体如 ...

  8. pandas 如何判断指定列是否(全部)为NaN(空值)

    判断某列是否有NaN df['$open'].isnull().any() # 判断open这一列列是否有 NaN 判断某列是否全部为NaN df['$open'].isnull().all() # ...

  9. 转载一篇pandas和,mysql

    http://pandas.pydata.org/pandas-docs/stable/comparison_with_sql.html#compare-with-sql-join http://bl ...

  10. TouchDelegate

    TouchDelegate(Rect bounds, View delegateView) Parameters: bounds Bounds in local coordinates of the ...