1 solutions

  • 0
    @ 2023-1-17 14:40:31

    image 裁剪部分的正方形边长最小是1厘米,最大不超过大正方形的一半,即 裁剪边长2 < 大正方形边长使用循环遍历,挨个进行判断,找出最大面积就可以啦,注意maxx初始化0,还有体积公式:体积=底面积高=(底面边长*底面边长)*高体积=底面积∗高=(底面边长∗底面边长)∗高

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n, max = 0;
        cin >> n;
        for (int i = 1;i * 2 < n; i++)
        {
            if ( (n - 2 * i) * (n - 2 * i) * i > max) 
                max = (n - 2 * i) * (n - 2 * i) * i;
        }
        cout << max;
        return 0;
    }
    
    
    • 1

    【入门】纸盒的最大体积是多少?

    Information

    ID
    687
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    4
    Uploaded By