本文主要是介绍hdu 5570 balls(高效),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接:hdu 5570 balls
代码
#include <cstdio>
#include <cstring>
#include <algorithm>using namespace std;
const int maxn = 1005;int N, M;
double A[maxn][maxn];int main () {while (scanf("%d%d", &N, &M) == 2) {for (int i = 1; i <= N; i++) {double sm = 0;for (int j = 1; j <= M; j++) {scanf("%lf", &A[i][j]);sm += A[i][j];}for (int j = 1; j <= M; j++) A[i][j] /= sm;}double ans = 0;for (int j = 1; j <= M; j++) {double mv = 0;for (int i = 1; i <= N; i++) {ans += A[i][j] * mv * 2 + A[i][j];mv += A[i][j];}}printf("%.2lf\n", ans);}return 0;
}
这篇关于hdu 5570 balls(高效)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!