AtCoder Beginner Contest 159 比赛人数8276 快,比赛开始后3分钟看到所有题
AtCoder Beginner Contest 159 C Maximum Volume 基本不等式
总目录详见https://blog.csdn.net/mrcrack/article/details/104454762
在线测评地址https://atcoder.jp/contests/abc159/tasks/abc159_c
![]()
![]()
y=(L-a-b)*a*b
求y的最大值,
因L-a-b+a+b=L
当且仅当L-a-b==a==b时取极大值
即a=L/3
AC代码如下
#include <stdio.h>
#define LL long long
int main(){
LL l;
scanf("%lld",&l);
printf("%.12lf\n",l*l*l*1.0/3/3/3);
return 0;
}
本文详细解析了AtCoder Beginner Contest 159中C题“最大体积”的解题思路与代码实现。通过分析题目给出的公式y=(L-a-b)*a*b,利用基本不等式确定了y的最大值出现条件,即当L-a-b==a==b时取得极大值,从而得出a=L/3。提供了完整的AC代码,使用C++语言,展示了如何快速计算给定长度L时的最大体积。

148

被折叠的 条评论
为什么被折叠?



