Combination of Physics and Maths

Combination of Physics and Maths

https://ac.nowcoder.com/acm/contest/5671/C

题意:
给你一个n*m的矩阵,求矩阵的子矩阵最大压强为多少,压力F为子矩阵所有元素之和,受力面积为子矩阵最后一行的元素之和?

思路:
由于我们只要求最大压力,所以我们根据公式求每一列的子列的最大压力即可。

代码:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

#define inf 1000000007
#define eps 0.00000001
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int maxn=100005;

inline int read()
{
    char c=getchar();
    int f=1, x=0;
    while(c>'9'||c<'0')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<3)+(x<<1)+(c^48);
        c=getchar();
    }
    return f*x;
}

double a[205][205];

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n, m;
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%lf",&a[i][j]);
            }
        }
        double ma=1;
        for(int i=0;i<m;i++)
        {
            double sum=0;
            for(int j=0;j<n;j++)
            {
                sum=sum+a[j][i];
                ma=max(ma,sum*1.0/a[j][i]);
            }
        }
        printf("%.8f\n",ma);
    }
    return 0;
}
全部评论

相关推荐

看到这个内容真是闹麻了。。。。。。现在有了AI以后很多人面试都会作弊吗?&nbsp;那对老老实实面试的人岂不是不公平....
程序员牛肉:公平那是对小孩子讲的童话故事,成年人的世界只有能不能接受失败的后果。 你要是能接受面试作弊被发现之后多家公司联合永久拉黑的后果,你就搞。
点赞 评论 收藏
分享
06-11 13:34
门头沟学院 C++
offe从四面八方来:我真的没时间陪你闹了
点赞 评论 收藏
分享
07-01 17:14
中北大学 Java
兄弟们是真是假
牛客46374834...:我在boss上投java岗从来没成功过
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务