problem Description
is Is Ai,jai,1+ai,2 was as the cost. Calculate the expectation of the cost.
Input
52 integers, n,m (1≤n≤,1≤m≤) then follows N Lines with M numbers ai,j (1≤ai≤)
Output
decimal places.
Sample Input
2 2 1 1 3 5 2 2 4 5 4 2 2 2 2 4 1 4
Sample Output
3.00 2.96 3.20
Source
bestcoder Round #63 (Div.2)
Attach Chinese title:
Attach the official puzzle:
1 #pragmaComment (linker, "/stack:1024000000,1024000000")2#include <iostream>3#include <cstdio>4#include <cstring>5#include <cmath>6#include <math.h>7#include <algorithm>8#include <queue>9#include <Set>Ten#include <bitset> One#include <map> A#include <vector> -#include <stdlib.h> -#include <stack> the using namespacestd; - #definePI ACOs (-1.0) - #defineMax (a) (a) > (b)? (a): (b) - #defineMin (a) (a) < (b)? (a): (b) + #definell Long Long - #defineEPS 1e-10 + #defineMOD 1000000007 A #defineN 1006 at #defineINF 1e12 - intn,m; - DoubleA[n][n]; - DoubleP[n][n]; - intMain () - { in while(SCANF ("%d%d", &n,&m) = =2){ - for(intI=0; i<n;i++){ to Doublesum=0; + for(intj=0; j<m;j++){ -scanf"%LF",&a[i][j]); thesum+=A[i][j]; * } $ for(intj=0; j<m;j++){Panax Notoginsengp[i][j]=a[i][j]*1.0/sum; - } the } + Doubleans=0; A for(intj=0; j<m;j++){ the Doublesum=0; + for(intI=0; i<n;i++){ -ans+=p[i][j]* (1.0-p[i][j]); $ } $ for(intI=0; i<n;i++){ -sum+=P[i][j]; - } theans+=sum*sum; - }Wuyiprintf"%.2lf\n", ans); the } - return 0; Wu}
View Code
HDU 5570 Balls (expected good title)