zoukankan      html  css  js  c++  java
  • Dummy Guy 几何

     Dummy Guy
    Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    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 n bottles 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

    inputoutput
    2
    
    2
    
    const double PI = acos(-1.0);
    int main() 
    {
        //freopen("in.txt","r",stdin);
        int n;
        while(cin>>n)
        {
            if(n == 1)
            {
                cout<<1<<endl;
                continue;
            }
            if(n == 2)
            {
                cout<<2<<endl;
                continue;
            }
            double angle = (PI - (2*PI/n))/2;
            //printf("%.8lf
    ", acos(angle));
            double ans = 1.0/cos(angle) +  1;
            printf("%.8lf
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    扫描线与悬线
    随机搜索与模拟退火
    树的直径相关
    分数规划及斜率优化
    数学-剩余系
    后缀数据结构
    AC自动机和KMP
    生命游戏和随机数之间某种不可言说的秘密
    转移了
    BZOJ 1710: [Usaco2007 Open]Cheappal 廉价回文
  • 原文地址:https://www.cnblogs.com/DreamHighWithMe/p/3425422.html
Copyright © 2011-2022 走看看