hdu-5645 DZY Loves Balls(水题)
题目链接:
DZY Loves Balls
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 105 Accepted Submission(s): 75
He has n balls in a big box. On each ball there is an integer written.
One day he decides to pick two balls from the box. First he randomly picks a ball from the box, and names it A. Next, without putting A back into the box, he randomly picks another ball from the box, and names it B.
If the number written on A is strictly greater than the number on B, he will feel happy.
Now you are given the numbers on each ball. Please calculate the probability that he feels happy.
t testcases follow. In each testcase, first line contains n, second line contains n space-separated positive integers ai, denoting the numbers on the balls.
(1≤t≤300,2≤n≤300,1≤ai≤300)
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; int a[600]; int main() {int t,n,k;scanf("%d",&t);while(t--){scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d",&a[i]);}double ans=0;for(int i=0;i<n;i++){for(int j=0;j<n;j++){if(i!=j){if(a[j]<a[i])ans+=1/(n*(n-1)*1.0);}}}printf("%.6lf\n",ans);}return 0; }
转载于:https://www.cnblogs.com/zhangchengc919/p/5296602.html
hdu-5645 DZY Loves Balls(水题)相关推荐
- HDU 5646 DZY Loves Partition
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5646 bc:http://bestcoder.hdu.edu.cn/contests/con ...
- HDU 6264 Super-palindrome(CCPC2017杭州) 水题
http://acm.hdu.edu.cn/showproblem.php?pid=6264 题目大意:给定字符串TTT,使得该字符串的每个长度为奇数的子串都是回文串,求至少要修改的字符的数量. 思路 ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...
- 【HDU - 5585】Numbers (水题,数学,数论)
题干: There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,otherwise ...
- HDU 2549 壮志难酬 (水题,但有个小坑!)
壮志难酬 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...
- HDU 5112 A Curious Matt 水题
A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) A. Bear and Three Balls 水题
A. Bear and Three Balls 题目连接: http://www.codeforces.com/contest/653/problem/A Description Limak is a ...
- HDU 5680 zxa and set 水题
zxa and set 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4681 Description zxa has a set A={a1,a2, ...
最新文章
- 对联广告,带关闭,可以移动
- Python学习的十个阶段,学完大成,对应一下看看你自己在哪个阶段
- 清华张悠慧:AI时代,「图灵完备」之后,「类脑计算完备」如何设计?
- Oracle 10g安装64位图解流程
- WPF and Silverlight 学习笔记(九):WPF布局管理之Canvas、InkCanvas
- IOS中http请求使用cookie
- CCNA考试的一点体会
- Explain:解决MUI 软键盘弹起挤压页面问题
- phpstorm破解安装
- sql的子查询超级慢-子查询酿的祸
- c语言设计第4章答案,《C语言程序设计》第4章习题答案.doc
- GoF的23种设计模式之创建型模式的特点和分类
- “找不到网络路径”的检测方法及解决方案
- poj 3897 Maze Stretching 二分+A*搜索
- [JSOI2010] 连通数
- linux不显示无线网卡驱动安装失败,无线网卡在Linux下安装
- AntColony 磁力搜索BT引擎的核心
- 苹果笔记本开机出现闪烁的问号文件夹解决方法
- 海马苹果助手ipad版_苹果IPA文件签名,软件掉签问题,自己也能轻松解决
- 【Spark Core】【RDD】【01】核心属性 执行原理