zoukankan      html  css  js  c++  java
  • CF 1100C NN and the Optical Illusion(数学)

    NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:

    It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.

    He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.

    Help NN find the required radius for building the required picture.

    Input

    The first and the only line of the input file contains two numbers n

    and r (3n100, 1r100) — the number of the outer circles and the radius of the inner circle respectively.

    Output

    Output a single number R— the radius of the outer circle required for building the required picture.

    Your answer will be accepted if its relative or absolute error does not exceed 106.

    Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when |ab|max(1,|b|)106.

    Sample Input

    Input
    3 1
    Output
    6.4641016
    Input
    6 1
    Output
    1.0000000
    Input
    100 100
    Output
    3.2429391

    题目意思:用n个外圆将半径为r的內圆包围起来,使得彼此之间能够相切,问外圆的半径为多少?

    解题思路:这是一道几乎题,我们需要引入辅助线


    我们设外圆的半径为R 我们可以得到左边(左右其实都一样)那个等腰三角形三角形的斜边长度为R+r,底边为R。又因为的所有圆心连接起来就是一个正多边形,我们知道多边形
    内角和为:π*(n-2)(这里外面小圆有多少个,n就为多少,这个可以在草稿本上画一下)。很明显,n个球可以分割成n个这样的等腰三角形。
    然后一个底角的角度为π*(n-2)/n/2;现在我们可以根据余弦公式得到:R/(R+r)=cos(a);这样就可以推出R:R=R=r*cos(a)/(1-cos(a));

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    #define PI acos(-1.0)
    using namespace std;
    int main()
    {
        double n,r,x;
        scanf("%lf%lf",&n,&r);
        x=PI*(n-2)/n;
        printf("%.7f
    ",r*cos(x/2)/(1-cos(x/2)));
        return 0;
    }
     
  • 相关阅读:
    说说爬虫分享
    飞机大战改进篇
    Unity WebGL WebSocket
    2048 控制台版(C#)
    C++多小球非对心弹性碰撞(HGE引擎)
    Unity中如何计算带minimap的贴图资源的大小
    【原】Unity 骨骼节点对象优化,AnimatorUtility.OptimizeTransformHierarchy
    ios sdk agree 无法通过,升级Mac系统到10.14,并且升级Xcode到最近版本后遇到
    【原】高光贴图参数放入颜色贴图的alpha通道中
    KBEngine游戏服务器(二)——运行Unity的Demo
  • 原文地址:https://www.cnblogs.com/wkfvawl/p/10505852.html
Copyright © 2011-2022 走看看