G - 確率(水题)
Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%lld & %llu
Description
话说当年语文考满分的你认识标题第一个字吗?
HPU有很多内湖,湖里面放养了很多金鱼(还有黑白天鹅?),每天都会有很多小伙伴在湖边看金鱼在水中嬉戏(黑白天鹅打架?)。
Ocean是一个善于思考的好孩子,今天他给你出了一道题目:
假设湖中一共有NN条金鱼,现在Ocean随机挑出两条金鱼,问这两条金鱼颜色不同的概率?
为了降低题目难度,Ocean认为金鱼只会有66种不同的颜色,即1,2,3,4,5,6。1,2,3,4,5,6。
PS:在挑出来第二条鱼之前,Ocean是不会将第一条鱼放入湖中的。
Input
每组数据占两行,第一行输入一个整数NN代表上面提到的信息。
下面一行输入NN个整数coloricolori,代表第ii条金鱼的颜色。
当colori=1colori=1,代表第ii条金鱼的颜色为11,其它依次类推。
注:1<=T<=100,2<=N<=100,1<=colori<=6。1<=T<=100,2<=N<=100,1<=colori<=6。
Output
Sample Input
2
4
1 1 2 2
2
2 2
Sample Output
0.67
0.00
Hint
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std; int fun(int x)
{
if(x<)
return ;
else
return x*(x-)/;
} int main()
{
int t,n,i,k,j;
int a[];
double p;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(a,,sizeof(a));
for(i=;i<n;i++)
{
scanf("%d",&k);
a[k]++;
}
k=fun(n);
j=;
for(i=;i<=;i++)
j+=fun(a[i]);
p=-j*1.0/k;
printf("%.2lf\n",p);
}
return ;
}
G - 確率(水题)的更多相关文章
- 暑假训练Round1——G: Hkhv的水题之二(字符串的最小表示)
Problem 1057: Hkhv的水题之二 Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- poj 1002:487-3279(水题,提高题 / hash)
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 236746 Accepted: 41288 Descr ...
- POJ2485Highways(prime 水题)
Highways Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26516 Accepted: 12136 Descri ...
- hdu 2050:折线分割平面(水题,递归)
折线分割平面 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- hdu 2044:一只小蜜蜂...(水题,斐波那契数列)
一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
随机推荐
- IOS 文件解析
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java ...
- 【327】Python 中 PIL 实现图像缩放
参考:Python 中使用PIL中的resize 进行缩放 参考:Python用Pillow(PIL)进行简单的图像操作(模糊.边缘增强.锐利.平滑等) 参考:廖雪峰 - Pillow 实现代码如下: ...
- MyBatis 动态SQL注意事项
- java中将数字的字符串表示转化为数字
int a = new Integer("1234").intValue() 或 int b = Integer.parseInt("1234") System ...
- Python3 abs() 函数
Python3 abs() 函数 Python3 数字 描述 abs() 函数返回数字的绝对值. 语法 以下是 abs() 方法的语法: abs( x ) 参数 x -- 数值表达式,可以是整数,浮 ...
- MySQL学习3---事务
MySQL 事务 MySQL 事务主要用于处理操作量大,复杂度高的数据. 在 MySQL 中只有使用了 Innodb 数据库引擎的数据库或表才支持事务. 事务处理可以用来维护数据库的完整性,保证成批的 ...
- linux 一个网卡配置多个IP
在Redhat系列(redhat,Fedora,Centos,Gentoo)中的实现方法如下: 1.单网卡绑定多IP在Redhat系列中的实现方法 假设需要绑定多IP的网卡是eth0,请在/etc/s ...
- Get The Client Info From PHP SERVER Arrary
Get The Client Info From PHP SERVER Arrary <?php date_default_timezone_set( "Asiz/Shanghai&q ...
- Solidity根据精度来表示浮点数
https://stackoverflow.com/questions/42738640/division-in-ethereum-solidity/42739843 pragma solidity ...
- DataTable记录
DataTable dt2 = dt.Copy();//复制结构和数据 //复制结构,不要数据 DataTable dt2 = new DataTable(); for (int i = 0; i & ...