Problem Description
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.
Input
Several test cases(about )

For each cases, first come  integers, n,m(≤n≤,≤m≤)

Then follows n lines with m numbers ai,j(≤ai≤)
 
Output
For each cases, please output the answer with two decimal places.
 
Sample Input

Sample Output
3.00
2.96
3.20
Source

附上中文题目:

附上官方题解:

 #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 ;
}

hdu 5570 balls(期望好题)的更多相关文章

  1. HDU 5570 balls 期望 数学

    balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 De ...

  2. HDU 5810 Balls and Boxes(盒子与球)

     Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  3. HDU 5984 数学期望

    对长为L的棒子随机取一点分割两部分,抛弃左边一部分,重复过程,直到长度小于d,问操作次数的期望. 区域赛的题,比较基础的概率论,我记得教材上有道很像的题,对1/len积分,$ln(L)-ln(d)+1 ...

  4. HDU 5570:balls 期望。。。。。。。。。。。。。。。

    balls  Accepts: 19  Submissions: 55  Time Limit: 6000/3000 MS (Java/Others)  Memory Limit: 65536/655 ...

  5. UVa 12230 && HDU 3232 Crossing Rivers (数学期望水题)

    题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不 ...

  6. hdu 5245 Joyful(期望的计算,好题)

    Problem Description Sakura has a very magical tool to paint walls. One day, kAc asked Sakura to pain ...

  7. HDU 4611 Balls Rearrangement (数学-思维逻辑题)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4611 题意:给你一个N.A.B,要你求 AC代码: #include <iostream> ...

  8. HDU 4611 Balls Rearrangement(2013多校2 1001题)

    Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  9. HDU 5245 上海大都会 J题 (概率期望)

    这道题的概率可以单独考虑每个格子对期望的贡献值.因为其实每个格子是否被选都可以认为是独立的,单独一个格子贡献的期望为1*(该格子K次被选的概率),所以答案其实就是每个格子K次被选中的概率之和. #in ...

随机推荐

  1. UESTC_传输数据 2015 UESTC Training for Graph Theory<Problem F>

    F - 传输数据 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit  ...

  2. poj 2411 新写法

    别以为我在刷水题.... 今天做了场srm,500pt想到了是dp但是无从下手,但是看了rng_58的神代码后顿觉海阔天空啊(盯着看了一个下午),相比于一年前的写法,真的是不忍直视啊, TC真是个好地 ...

  3. 【转】android camera(一):camera模组CMM介绍

    关键词:android  camera CMM 模组 camera参数平台信息:内核:linux系统:android 平台:S5PV310(samsung exynos 4210)  作者:xubin ...

  4. 序列变换(Lis变形)

    序列变换 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. log4net 使用与配置 每天一份log文件

    1.下载 或 在nuget安装 log4net 2. web.config (app.config) <configuration> <configSections> < ...

  6. JDK5新特性之线程同步集合(五)

    一. 传统集合: 传统方式下的Collection在迭代集合时, 不同意对集合进行改动: public class CollectionModifyExceptionTest { public sta ...

  7. java学习笔记day05

    1.final关键字:防止被继承的类或覆写的方法修改,变量或方法被final定义后  会在内在中存在 特点:   1)可以修饰类.函数.变量.   2)被final修饰的类不可以被继承.   3)被f ...

  8. oracle linux 安装过程错误 :Error in invoking target ‘agent nmhs’ of makefile

    Problem:When installing 11.2.0.4 on Redhat 7: Error in invoking target 'agent nmhs' of makefile '/u0 ...

  9. c#之process类相关整理

    一.根据进程名获取进程的用户名?   需要添加对 System.Management.dll 的引用   using System.Diagnostics; using System.Manageme ...

  10. java字符串数组进行大小排序

    若是将两个字符串直接比较大小,会包:The operator > is undefined for the argument type(s) java.lang.String, java.lan ...