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;
    }
  • 相关阅读:
    潜水一年,然后回来
    【搬运】Visual Studio vs2017 vs2019 中文离线安装包下载,替代ISO镜像
    Re0:在 .NetCore中 EF的基本使用
    Re0:在.NetCore 中Dapper的基本用法
    jdadjkgh.txt
    Android Studio打包出来的安装包是非正式发布版本
    Android Studio生成开发调试版(Debug)和正式发布版(Release)的安装包
    【unity-2】coroutine
    【ugui-1】RectTransformUtility
    [ps笔记]快捷键、快捷方式
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781850.html
Copyright © 2011-2022 走看看