0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC備忘録[ABC159 C - Maximum Volume] (Python)

Posted at

#問題文
正の整数$L$が与えられます。縦、横、高さの長さ(それぞれ、整数でなくてもかまいません) の合計が$L$の直方体としてありうる体積の最大値を求めてください。

#制約
$1≤L≤1000$
$L$は整数

C - Maximum Volume
#解法
縦、横、高さの長さをそれぞれ$a,b,c$とおくと3変数の相加相乗平均を利用して最大値を求める問題に帰着する。

L = int(input())
a = L / 3

print(a ** 3)

##3変数の相加相乗平均
$a,b,c \geq0$のとき$a+b+c\geq3\sqrt[3]{abc}$が成り立ち、$a=b=c$のときに等号が成立する。
この不等式を変形すると、$(\frac{a+b+c}{3})^3\geq abc$となり等号が成立するときに$abc$が最大となる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?