hdu 5570 balls(期望好题)
There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,+ai,+...+ai,m. If the number of balls with the j-th is x, then you should pay x2 as the cost. Please calculate the expectation of the cost.
Several test cases(about ) For each cases, first come integers, n,m(≤n≤,≤m≤) Then follows n lines with m numbers ai,j(≤ai≤)
For each cases, please output the answer with two decimal places.
3.00
2.96
3.20
附上中文题目:

附上官方题解:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1006
#define inf 1e12
int n,m;
double a[N][N];
double p[N][N];
int main()
{
while(scanf("%d%d",&n,&m)==){
for(int i=;i<n;i++){
double sum=;
for(int j=;j<m;j++){
scanf("%lf",&a[i][j]);
sum+=a[i][j];
}
for(int j=;j<m;j++){
p[i][j]=a[i][j]*1.0/sum;
}
}
double ans=;
for(int j=;j<m;j++){
double sum=;
for(int i=;i<n;i++){
ans+=p[i][j]*(1.0-p[i][j]);
}
for(int i=;i<n;i++){
sum+=p[i][j];
}
ans+=sum*sum;
}
printf("%.2lf\n",ans);
}
return ;
}
{3BKPSJUAOIDU@)[CH.png)
hdu 5570 balls(期望好题)的更多相关文章
- HDU 5570 balls 期望 数学
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 De ...
- HDU 5810 Balls and Boxes(盒子与球)
Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- HDU 5984 数学期望
对长为L的棒子随机取一点分割两部分,抛弃左边一部分,重复过程,直到长度小于d,问操作次数的期望. 区域赛的题,比较基础的概率论,我记得教材上有道很像的题,对1/len积分,$ln(L)-ln(d)+1 ...
- HDU 5570:balls 期望。。。。。。。。。。。。。。。
balls Accepts: 19 Submissions: 55 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/655 ...
- UVa 12230 && HDU 3232 Crossing Rivers (数学期望水题)
题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不 ...
- hdu 5245 Joyful(期望的计算,好题)
Problem Description Sakura has a very magical tool to paint walls. One day, kAc asked Sakura to pain ...
- HDU 4611 Balls Rearrangement (数学-思维逻辑题)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4611 题意:给你一个N.A.B,要你求 AC代码: #include <iostream> ...
- HDU 4611 Balls Rearrangement(2013多校2 1001题)
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- HDU 5245 上海大都会 J题 (概率期望)
这道题的概率可以单独考虑每个格子对期望的贡献值.因为其实每个格子是否被选都可以认为是独立的,单独一个格子贡献的期望为1*(该格子K次被选的概率),所以答案其实就是每个格子K次被选中的概率之和. #in ...
随机推荐
- < IOS > IOS适配,简单的分析解决一下
版权:张英堂 欢迎转载,转载请注明出处. 做的项目很多,一到适配的时候头就大了,IOS6,7的适配,屏幕的适配,当然还有下一步要出4.7屏幕,也要做适配....悲剧的移动端的人员. 怎么做一个通用的适 ...
- poj 3311 Hie with the Pie(状态压缩dp)
Description The Pizazz Pizzeria prides itself or more (up to ) orders to be processed before he star ...
- sh_脚本语法
介绍: 1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编写脚 ...
- Calculation(dfs+状压dp)
Problem 1608 - Calculation Time Limit: 500MS Memory Limit: 65536KB Total Submit: 311 Accepted: ...
- 九度OnlineJudge之1032:ZOJ
题目描述: 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出. 输入: 题目包含多组用例,每组用例占一行,包含ZOJ三个 ...
- AjaxHelper的get和post请求的封装类
最近在学习ajax的时候发现不断的调用get和post请求时,代码重复很多,有的公司会用自带的封装的方法,这个可以直接调用ajax的方法,但是在运用的时候我们也应该学习它是怎么封装的和一些原理性的东西 ...
- SQLServer服务器数据库之间的数据操作(完整版)
分类: 数据库开发技术 ---------------------------------------------------------------------------------- -- Au ...
- JS 中刷新页面的方法
整理了就是这几种,,有些在IE下面是不支持的,慎用... 1,history.go(0) 2,location.reload() 3,location=location 4,location.assi ...
- android学习—should use @string resource警告
在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "BUTTON", should use @string resource <Button ...
- Object转换为JSON格式字符串
简介: 把JS的Object转换为Json字符串. 代码: function ObjectToJson(object) { // Object转换为josn var json = "&quo ...