当前位置: 代码迷 >> 综合 >> 【多校联赛】Combination of Physics and Maths
  详细解决方案

【多校联赛】Combination of Physics and Maths

热度:8   发布时间:2024-02-04 20:49:33.0

Combination of Physics and Maths

题意:

计算上面的压强

题解:

首先最大值一定是单列,所以直接遍历就可以了

代码:
///Combination of Physics and Maths
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
struct pp
{double s;int num;
}p[205];
double cmp(pp a,pp b)
{return a.s>b.s;
}
int main()
{long long int t,n,m,i,j,F,S,a[205][205];double P;scanf("%lld", &t);while(t--){scanf("%lld%lld",&n, &m);F=S=0;for(i=0;i<n;i++){for(j=0;j<m;j++){scanf("%lld", &a[i][j]);F+=a[i][j];if(i==n-1)S+=a[i][j];}}double ans=0;for ( i = 0; i < m; i++){double tt = 0;for (j = 0; j < n; j++) {tt = tt + a[j][i];ans = max(ans, tt / a[j][i]);}}printf("%.8lf\n",ans);}return 0;
}