「Codeforces 1100C」NN and the Optical Illusion 题解
题意
- 一个半径为\(r\)的圆,与\(n\)个半径为\(R\)的圆相切且这\(n\)个圆分别和左右的两个圆相切
- 已知\(n, r\),求\(R\)
思路
将外圈圆的圆心相连, 围成一个正\(n\)边形 - 从多边形截出一个\(\triangle BGA\) - \(\angle BGA=\frac{\angle BGF}{2}=\frac{180^{\circ}-\frac{360^{\circ}}{n}}{2}\) - 做\(\triangle BGA \space BG\)边上的高\(AH\) - 得到\(Rt\triangle GHA,GH=R,GA=R+r\) - \(\frac{GA}{GH}=\frac{R+r}{R}=\sec\angle BGA\) - \(R\cdot \sec\angle BGA=R+r\) - \(R\cdot(\sec\angle BGA-1)=r\) - \(R=\frac{r}{\sec\angle BGA-1}=\frac{r}{\sec(\frac{180^{\circ}-\frac{360^{\circ}}{n}}{2})-1}\)
注意事项
- cmath里没有\(\sec\),可以用\(\cos\)的倒数嘛
- cmath里面的所有三角函数都是弧度制,要将角度\(\times\pi\div180\)
备注
绘图工具:GeoGebra Geometry ## 代码(C++) 1
2
3
4
5
6
7
8
9
10int n;
double r;
read(n);
std::cin >> r;
double degree = 180 - (360.0 / n);
degree /= 2;
degree = degree / 180 * PI;
double ans=r / (1 / cos(degree) - 1);
std::cout.precision(7);
std::cout << std::fixed << ans << std::endl;
「Codeforces 1100C」NN and the Optical Illusion 题解
https://blog.seniorious.cc/2019/CF-1100C/