Project Euler 317

Project Euler 317

题目

Firecracker

A firecracker explodes at a height of $100 \text{m}$ above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of $20 \text{m/s}$.

We assume that the fragments move without air resistance, in a uniform gravitational field with $g=9.81 \text{m/s}^2$.

Find the volume (in $\text{m}^3$) of the region through which the fragments move before reaching the ground.

Give your answer rounded to four decimal places.

解决方案

可以发现,所要求解的物体是一个绕$y$轴旋转体。

假设抛出的物体的方向和$x$轴正方向的夹角为$\theta$,并且当前时间为$t$。那么可以列出如下$(x,y)$关于$(\theta,t)$的参数方程:

将$y$固定,在此约束下$t$和$\theta$要取适当的值使得$x$取到最大值,这个过程用拉格朗日乘数法解决。

因此,可以写出

计算得到:

令$\dfrac{\partial \mathcal{L}}{\partial t}=0,\dfrac{\partial \mathcal{L}}{\partial \theta}=0$,那么得到式子$v=gt\sin\theta$。然后联立$x=vt\cos\theta,y=h+vt\sin\theta-\dfrac{1}{2}gt^2$,那么得到最终的曲线的方程:

当物体从竖直向上抛出时,能够达到的高度最高,为$H=h+\dfrac{v^2}{2g}$。

因此,答案为

代码

1
2
3
4
5
6
7
8
from math import pi

h = 100
v = 20
g = 9.81
ans = pi * (2 * g * v * h + v ** 3) ** 2 / (4 * g ** 3)
print("{:.4f}".format(ans))

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
Ujimatsu Chiya 微信 微信
Ujimatsu Chiya 支付宝 支付宝