Project Euler 317 Firecracker

开启传送门

题目描述

A firecracker explodes at a height of $100$ 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 m/s$.

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

Find the volume (in $m^3$) of the region through which the fragments move before reaching the ground. Give your answer rounded to four decimal places.

题意

一个爆竹在 $100$ 米的高度上爆炸了,碎片以 $20m/s$ 的速度往四面八方迸射。假设当地有 $g = 9.81m/s^2$ 的均匀重力加速度。问你所有碎片经过的体积。

分析

其实我刚拿到题就意识到可能是一个我不会的知识。

然后队友想都没想来了句,抛物线的包络线。。。orz

如果知道包络线这种东西就很简单了。推导过程如下:

$ x = u \cdot cos\theta \cdot t$

$ y = u \cdot sin\theta \cdot t - \frac{1}{2} g \cdot t^2 + 100$

联立后消去 $t$ :

$y = tan\theta \cdot x - \frac{g \cdot sec^2\theta}{2u^2} \cdot x^2 + 100$

对 $\theta$ 求导有:

$\frac{dy}{d\theta} = sec^2\theta \cdot x - \frac{g \cdot x^2}{u^2} tan\theta \cdot sec^2\theta$

令上式等于 $0$ 有:

$tan\theta = \frac{u^2}{gx}$

带到原式有:

$y = \frac{u^2}{2g} - \frac{g \cdot x^2}{2u^2} + 100$

$\therefore y_{max} = \frac{u^2}{2g} + 100$

$\therefore x^2 = \frac{u^4}{g^2} - \frac{2u^2Y}{g} + \frac{200u^2}{g}$

然后对每个圆积分,有

$answer = \big(\int_{0}^{100+\frac{u^2}{2g}} \frac{u^4}{g^2} - \frac{2u^2Y}{g} + \frac{200u^2}{g}dY\big)\pi = \frac{u^4Y}{g^2} - \frac{u^2Y^2}{g} + \frac{200u^2Y}{g}\big|_0^{100+\frac{u^2}{2g}}*\pi$

代码

这题我是手算的 (/ω\)