zoukankan      html  css  js  c++  java
  • URAL 1984. Dummy Guy(数学啊)

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1984


    1984. Dummy Guy

    Time limit: 0.5 second
    Memory limit: 64 MB
    Problem illustration
    Every year students of our university participate in Regional Contest in Saint Petersburg. Train journeys from Yekaterinburg to Saint Petersburg make students very thirsty, so they usually take a lot of drinks with them. But the director of Institute of Mathematics and Computer Sciences doesn’t like when students carry all these bottles. So the students try to hide their bottles from the director. The Psych Up team invented a special device for that: a dummy guy.
    The very first journey showed that the dummy guy can hardly hide two bottles. So you have decided to make a new dummy guy. You have nbottles that can be considered as cylinders of a unit radius. At first you want to draw a circle and place all your bottles inside it so that each of the bottle bottoms touches the circle. What is the minimum radius of such circle?

    Input

    The only line contains an integer n that is the number of bottles (1 ≤ n ≤ 10).

    Output

    Output the minimum radius of a circle with an absolute or relative error not exceeding 10−6.

    Sample

    input output
    2
    
    2

    题意:

    求一个大圆能包括n个半径为一的小圆的最小半径!

    PS:

    把每一个小圆的圆心连起来就是一个正n多边形,就是求多边形中心到顶点的距离,画一条与小圆相切的切线,构成一个直角三角形,用正弦定理就能够求出来。再加上一个小圆的半径1。就好了,绘图就明确了!

    代码例如以下:

    #include <cstdio>
    #include <cmath>
    #define PI acos(-1.0)
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            if(n == 1)
            {
                printf("1
    ");
                continue;
            }
            double ans = 1.0/(sin(PI*1.0/n));
            ans += 1;
            printf("%.6lf
    ",ans);
        }
        return 0;
    }


  • 相关阅读:
    0714买卖股票的最佳时机含手续费 Marathon
    0070爬楼梯 Marathon
    0045跳跃游戏II Marathon
    0343整数拆分 Marathon
    0406根据身高重建队列 Marathon
    0096不同的二叉搜索树 Marathon
    0763划分子母区间 Marathon
    0435无重叠区间 Marathon
    0452用最少数量的箭引爆气球 Marathon
    0509斐波那契数 Marathon
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/6818721.html
Copyright © 2011-2022 走看看