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;
    }
     
  • 相关阅读:
    css选择器
    js中event.target和event.srcElement的区别
    js生成10个20-50之间的随机数(包含20和50)
    chrome jsonView插件安装 在浏览器地址栏里输入接口后返回的json数据格式化
    JS字符串使用占位符轻松实现拼接(来自react源码)
    linux + node + yarn + git + ssh + linux免密登录 + pm2自动部署
    react tab切换 第一次切换到某个页面时会请求数据,以后不会再请求数据
    解决方案:sublime Text 3 无法安装插件有关问题 (JSON文件schema_version问题)
    ES6解构代替concat数组拼接
    2019年最新web前端笔试题
  • 原文地址:https://www.cnblogs.com/wkfvawl/p/10505852.html
Copyright © 2011-2022 走看看