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;
    }
  • 相关阅读:
    在linux上安装python, jupyter, 虚拟环境(virtualenv)以及 虚拟环境管理之virtualenvwraper
    linux
    Django ORM那些相关操作
    Django 中 form 介绍
    MySQL完整性约束
    git入门
    MySQL表的操作
    努力努力再努力
    Docker初始
    IO模型
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781850.html
Copyright © 2011-2022 走看看