2020牛客暑期多校训练营(第六场)C——Combination of Physics and Maths

题目链接

2020牛客暑期多校训练营(第六场)C——Combination of Physics and Maths_第1张图片
2020牛客暑期多校训练营(第六场)C——Combination of Physics and Maths_第2张图片

看图~~~~
2020牛客暑期多校训练营(第六场)C——Combination of Physics and Maths_第3张图片

#include 
using namespace std;
const int N = 300;
double Sum[N][N];
int main()
{ 
    ios::sync_with_stdio(false); cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        int n,m;
        cin>>n>>m;
        int A;
        double tem = 0;
        for(int i = 1;i<=n;i++)
        {//注意i和j都要从1开始,便于下面的递推
            for(int j = 1;j<=m;j++){
                cin>>A;
                Sum[i][j] = Sum[i-1][j]+A;
                tem = max(tem,Sum[i][j]*1.0/A);//由于Sum是int类型,所以最好*1.0,不乘也没关系,你晓得为啥
            }
        } 
        printf("%.8f\n",tem);
        memset(Sum,0,sizeof Sum);//有人认为这句是多余的,但是你看一下前面的T,你就知道它就是你的唯一了
    }
}

你可能感兴趣的:(牛客2020多校联赛)