UVA11646 题解
FurippuWRY
·
·
题解
数学推柿子题。
题意:给出一条跑道长和宽的比例,求这个跑道长和宽实际的长度(跑道的两弧和两长相加等于 400)。
如图,\overset{\frown}{AB}+\overset{\frown}{CD}+AD+BC=400,很明显 \overset{\frown}{AB}=\overset{\frown}{CD},AD=BC,则有 \overset{\frown}{AB}+AD=\overset{\frown}{CD}+BC=200。
先约定一些符号:比例长为 x,比例宽为 y。
首先可以通过 400 减去两弧长得到两边长。在角度制下,弧长为 \dfrac{n^{\circ}\pi r}{180},其中 n 为角度,r 为半径,这题中的 r 即为 AE,BE,CE,DE,所以
\overset{\frown}{AB}=\overset{\frown}{CD}=\dfrac{\angle AEB \times \pi \times AE}{180}=\dfrac{\angle CED \times \pi \times CE}{180}
但这题需要在弧度制下讨论,因为 1^{\circ}=\dfrac{\pi}{180}\mathrm{rad},所以
\overset{\frown}{AB}=\overset{\frown}{CD}=\angle AEB \times AE=\angle CED \times CE
因为 \angle AEB 与 \angle CED 是 \angle EAD,\angle EDA 的外角,则
\begin{aligned}\angle AEB=\angle CED&=2\times\angle EAD=2\times\angle EDA\\&=2\times\arctan \dfrac{CD}{AD}=2\times\arctan\dfrac yx\end{aligned}
根据勾股定理可得 AE=CE=\dfrac{\sqrt{x^2+y^2}}{2},则有
\overset{\frown}{AB}=\overset{\frown}{CD}=2\times\arctan\dfrac yx\times \dfrac{\sqrt{x^2+y^2}}{2}=\sqrt{x^2+y^2}\times \arctan\dfrac yx
所以
\sqrt{x^2+y^2}\times \arctan\dfrac yx+x=200
然后输出 \dfrac{200}{\sqrt{x^2+y^2}\times \arctan\dfrac yx+x} 分别与 x,y 的乘积即可。
#include<bits/stdc++.h>
using namespace std;
double l, w;
double f(double x, double y) {
return 200 / (sqrt(x * x + y * y) * (atan(y / x)) + x);
}
int main() {
for (int i = 1; ~scanf("%lf : %lf", &l, &w); i++) {
printf("Case %d: %.10lf %.10lf\n", i, f(l, w) * l, f(l, w) * w);
}
return 0;
}