码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1984. Dummy Guy(数学啊)

时间:2015-03-14 09:37:19      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:数学   ural   

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


1984. Dummy Guy

Time limit: 0.5 second
Memory limit: 64 MB
技术分享
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\n");
            continue;
        }
        double ans = 1.0/(sin(PI*1.0/n));
        ans += 1;
        printf("%.6lf\n",ans);
    }
    return 0;
}


URAL 1984. Dummy Guy(数学啊)

标签:数学   ural   

原文地址:http://blog.csdn.net/u012860063/article/details/44256749

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!