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;
    }


  • 相关阅读:
    Java线程:新特征-阻塞栈
    Java线程:新特征-阻塞队列
    Java线程:新特征-信号量
    Java线程:新特征-锁(下)
    Java线程:新特征-锁(上)
    Java线程:新特征-有返回值的线程
    Java线程:新特征-线程池
    Java线程:volatile关键字
    Java线程:并发协作-死锁
    通过Roslyn动态生成程序集
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/6818721.html
Copyright © 2011-2022 走看看