hdu 5570 balls(期望好题)
2015-11-22 14:59
309 查看
[align=left]Problem Description[/align]
[align=left]Input[/align]
[align=left]Output[/align]
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
[align=left]Source[/align]
BestCoder Round #63 (div.2)
附上中文题目:
View Code
There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+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.
[align=left]Input[/align]
Several test cases(about 5) For each cases, first come 2 integers, n,m(1≤n≤1000,1≤m≤1000) Then follows n lines with m numbers ai,j(1≤ai≤100)
[align=left]Output[/align]
For each cases, please output the answer with two decimal places.
[align=left]Sample Input[/align]
2 2 1 1 3 5 2 2 4 5 4 2 2 2 2 4 1 4
[align=left]Sample Output[/align]
3.00 2.96 3.20
[align=left]Source[/align]
BestCoder Round #63 (div.2)
附上中文题目:
#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 ; double p ; int main() { while(scanf("%d%d",&n,&m)==2){ for(int i=0;i<n;i++){ double sum=0; for(int j=0;j<m;j++){ scanf("%lf",&a[i][j]); sum+=a[i][j]; } for(int j=0;j<m;j++){ p[i][j]=a[i][j]*1.0/sum; } } double ans=0; for(int j=0;j<m;j++){ double sum=0; for(int i=0;i<n;i++){ ans+=p[i][j]*(1.0-p[i][j]); } for(int i=0;i<n;i++){ sum+=p[i][j]; } ans+=sum*sum; } printf("%.2lf\n",ans); } return 0; }
View Code
相关文章推荐
- List sublist的toIndex不能超过500
- 大数据时代对企业营销行为的价值
- 4-7 统计某类完全平方数
- layer的核心动画的基本属性
- C语言素数的多种求法
- DH11数字温湿度传感器
- git remote基本使用
- 第五章 Android事件处理机制
- M1阶段个人总结
- sql server中高并发情况下 同时执行select和update语句死锁问题
- UI事件处理:手势处理
- sqlserver进程死锁的解决办法(一)
- Visio对象插入Word后周围空白过大
- android中实现view可以滑动的六种方法续篇(二)
- BZOJ 3195: [Jxoi2012]奇怪的道路(状压dp)
- position()与offset()区别
- Quart2D绘图 绘制imageView的笔记
- 振动传感器
- [LeetCode]Binary Tree Preorder Traversal
- IJHIT杂志