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;
    }
  • 相关阅读:
    关于 platform的文章
    S3C2440驱动篇—Linux平台设备驱动
    class_create(),class_device_create()或device_create()自动创建设备文件结点
    耳机接线图
    GNOME图形界面
    ssh登录过程中 出现 unsupport gssapiauthentication及pscp传输文件出现 ssh_init: Network error: Cannot assign requested address错误
    du和df 的使用及区别
    bash中的set指令使用说明
    qemuimg dd使用
    linux lvm卷的总结,在proxmox 5下测试验证
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781850.html
Copyright © 2011-2022 走看看