HDU 2023. 求平均成绩(谁说水题不会卡你呢)
原题链接
简单
作者:
史一帆
,
2021-05-30 21:27:45
,
所有人可见
,
阅读 262
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 60;
int n, m;
int f[N][10];
double sum[10];
int main()
{
while (~scanf("%d%d",&n,&m))
{
memset(f, 0, sizeof f);
memset(sum, 0, sizeof sum);
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= m; j ++ )
{
cin >> f[i][j];
f[i][8] += f[i][j];
sum[j] += f[i][j];
}
for (int i = 1; i <= n; i ++ )
{
if (i != n) printf("%.2lf ", f[i][8] * 1.0 / m);
else printf("%.2lf\n", f[i][8] * 1.0 / m);
}
for (int i = 1; i <= m; i ++ )
{
if (i != m) printf("%.2lf ", sum[i] *= 1.0 / n);
else printf("%.2lf\n", sum[i] *= 1.0 / n);
}
int ans = 0;
for (int i = 1; i <= n; i ++ )
{
int flag = 1;
for (int j = 1; j <= m; j ++ )
{
if (f[i][j] < sum[j])
{
flag = 0;
break;
}
}
if (flag) ans++;
}
printf("%d\n\n",ans);
}
return 0;
}