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;
    }
  • 相关阅读:
    Spring 实践 -IoC
    HDU1584:蜘蛛牌(DFS)
    Linux命令缩写来由
    一道面试题:用shell写一个从1加到100的程序
    常用的OpenCV函数速查
    等差数列/等比数列通项公式与求和公式
    ubuntu给手机建wifi
    [转]C++之运算符重载(2)
    [转]C++之运算符重载(1)
    [转]C++之多态性与虚函数
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781850.html
Copyright © 2011-2022 走看看