hdoj5645DZY Loves Balls
He has n
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
into the box, he randomly picks another ball from the box, and names it B
If the number written on A
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.
the number of testcases.
t
follow. In each testcase, first line contains n
second line contains n
positive integers a
denoting the numbers on the balls.
(1≤t≤300,2≤n≤300,1≤a
2
3
1 2 3
3
100 100 100
0.500000
0.000000
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int i,j,a[9999];
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
double sum;
sum=n*(n-1);
double ans=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(a[j]>a[i])
ans++;
}
}
double p;
p=ans/sum;
printf("%.6lf\n",p);
}
return 0;
}
思路:签到水题。
hdoj5645DZY Loves Balls的更多相关文章
- HDU 5194 DZY Loves Balls
DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu 5645 DZY Loves Balls
DZY Loves Balls Accepts: 659 Submissions: 1393 Time Limit: 4000/2000 MS (Java/Others) Memory Lim ...
- HDU 5645 DZY Loves Balls 水题
DZY Loves Balls 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5645 Description DZY loves playing b ...
- hdu5194 DZY Loves Balls 【概率论 or 搜索】
//yy:那天考完概率论,上网无聊搜个期望可加性就搜到这题,看到以后特别有亲和感,挺有意思的. hdu5194 DZY Loves Balls [概率论 or 搜索] 题意: 一个盒子里有n个黑球和m ...
- BC#76.2DZY Loves Balls
DZY Loves Balls Accepts: 659 Submissions: 1393 Time Limit: 4000/2000 MS (Java/Others) Memory Lim ...
- hdoj 5194 DZY Loves Balls【规律&&gcd】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5194 题意:给你n个黑球,m个白球,每次从中随机抽取一个,如果抽到黑球记为1如果抽出来白球记为0,让你 ...
- HDU 5645
DZY Loves Balls Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others ...
- hdu 5194(DFS)
DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- Microsoft Loves Linux
微软新任CEO纳德拉提出的“Microsoft Loves Linux”,并且微软宣布.NET框架的开源,近期Microsoft不但宣布了Linux平台的SQL Server,还宣布了Microsof ...
随机推荐
- 利用gmpy2破解rsa
gmpy2的相关文档: https://gmpy2.readthedocs.io/en/latest/ ================ 题目: 来自实验吧的rsarsa:http://www.shi ...
- BeanFactoryAware和BeanNameAware
实现 BeanFactoryAware 接口的 bean 可以直接访问 Spring 容器,被容器创建以后,它会拥有一个指向 Spring 容器的引用. BeanFactoryAware 接口只有一个 ...
- Cable master POJ - 1064
Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Commi ...
- hdu 2433 Travel(还不会)
Problem Description One day, Tom traveled to a country named BGM. BGM is a small country, but ...
- redis:CLUSTER cluster is down 解决方法
redis:CLUSTER cluster is down 解决方法 首先进入安装目录的src下: 1. ./redis-trib.rb check 127.0.0.1:7001 检查问题所在 2. ...
- Linux下sublime的中文输入问题
比较久了,今天找到了解决方案: git clone https://github.com/lyfeyaj/sublime-text-imfix.git cd sublime-text-imfix &a ...
- 单点登录 SSO, 自动登录 , java 加密,ssl原理, Tomcat配置SSL
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 单点登录的英文简称为SSO(single sign on),单点登录功能使得用户只要登录 ...
- 又见Python<2>:如何安装第三方库(Windows)
使用python进行数据分析或者数据处理时,往往需要使用一些库,而使用库之前必须安装它.Anaconda内置了很多常用的第三方库,可以满足绝大部分需求,比如numpy.pandas.matplotli ...
- codevs 1226 倒水问题
1226 倒水问题 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 有两个无刻度标志的水壶,分别可装 x 升和 y 升 ( x, ...
- bzoj 4094: [Usaco2013 Dec]Optimal Milking
4094: [Usaco2013 Dec]Optimal Milking Description Farmer John最近购买了N(1 <= N <= 40000)台挤奶机,编号为1 . ...