zoukankan      html  css  js  c++  java
  • Codeforces Round #532 (Div. 2)- C(公式计算)

    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 nn and the radius of the inner circle rr. NN thinks that, using this information, you can exactly determine the radius of the outer circles RR 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 nn and rr (3≤n≤1003≤n≤100, 1≤r≤1001≤r≤100) — the number of the outer circles and the radius of the inner circle respectively.

    Output

    Output a single number RR — 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 10−610−6.

    Formally, if your answer is aa and the jury's answer is bb. Your answer is accepted if and only when |a−b|max(1,|b|)≤10−6|a−b|max(1,|b|)≤10−6.

    Examples

    input

    Copy

    3 1
    

    output

    Copy

    6.4641016
    

    input

    Copy

    6 1
    

    output

    Copy

    1.0000000
    

    input

    Copy

    100 100
    

    output

    Copy

    3.2429391

    思路:利用公式计算,考虑一下精度就ok了(可以用acos(-1)来计算pi)

    代码:

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #define PI 3.141592654
    using namespace std;
    
    int main()
    {
    	
    	double n,r;
    	cin>>n>>r;
    	
    	printf("%.7f",r*sin(PI/n)/(1-sin(PI/n)));
    	
    	return 0;
    }
  • 相关阅读:
    什么是进程!
    【2016.5.9】不考研,那就好好学
    ajax的秘密
    Input标签中Type的类型及详细用法
    html5 Canvas颜色渐变(画图很重要)
    页面的自动滚动效果
    HTML:让表单 文本框 只读,不可编辑的方法
    <s:property/>标签
    在HTML中实现上划线,中划线和下划线
    Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781850.html
Copyright © 2011-2022 走看看