zoukankan      html  css  js  c++  java
  • HDU 4798 Skycity

    Skycity

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 269    Accepted Submission(s): 63


    Problem Description
    The world's new tallest building is going to be built in Changsha, which will be called as "Skycity". The Skycity is going to be built as a circular truncated cone, radius of its bottom is marked as R, and radius of its top is marked as r, height of the building is marked as H, and there will be F floors with exact the same height in the whole building.
    After construction of the building's skeleton, the construction team is going to construct the curtain wall using thousands of glass panes. The curtain wall is installed in each floor. When installing the curtain wall in a floor, first the construction team will measure the radius r' of the ceiling, then they will install the glass curtain wall as a regular prism which can exactly contain the ceiling circle. When constructing the glass curtain wall, all the glass pane has a minimum area requirement S, and amount of glass usage should be as little as possible.

    As all the glass has exact the same thickness, so we can calculate the consumption of each glass pane as its area. Could you calculate the minimum total glass consumption?
     
    Input
    There will be multiple test cases. In each test case, there will be 5 integers R, r (10 ≤ r < R ≤ 10000), H (100 ≤ H ≤ 10000), F (10 ≤ F ≤ 1000) and S (1 ≤ S <× r × H ÷ F) in one line.
     
    Output
    For each test case, please output the minimum total glass consumption, an absolute error not more than 1e-3 is acceptable.
     
    Sample Input
    50 10 800 120 5 300 50 2000 500 10
     
    Sample Output
    149968.308
    2196020.459
     
    Source
     

    这条是2013年长沙的题目

    二分的题目就是卡姿势,同浮点误差~

    二分姿势稍有不当就WA  

    求第 i 层的圆的半径一层层的加又WA , 要直接用公式  ri = add * i + r ;

    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <algorithm>
    #include <cmath>
    using namespace std;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    inline double getlen(int n,double r)
    {
        return 2.0 * r * tan( PI / n );
    }
    int main()
    {
        ios::sync_with_stdio(0);
    
        #ifdef LOCAL
            freopen("in.txt","r",stdin);
        #endif // LOCAL
    
        double R,r,H,F,S;
        while( cin >> R >> r >> H >> F >> S ){
            double h = H / F , ans = 0 , add = ( R - r ) / F , ri  ;
    
            for( int i = 0 ; i < F ; i++ )
            {
                ri = add * i  + r ;
                int ll = 3 ,rr = 100000 ;
                double area ;
                int num;
                while( ll <= rr )
                {
                    int mm = ( ll + rr ) >> 1;
                    double tmp = getlen( mm , ri ) * h;
                    if( S + eps < tmp ){
                        area = tmp , num = mm;
                        ll = mm + 1;
                    }
                    else{
                        rr = mm - 1;
                  }
            } ans
    += num * area; } printf("%.3lf ",ans); } return 0; }
    only strive for your goal , can you make your dream come true ?
  • 相关阅读:
    网卡驱动-BD详解(缓存描述符 Buffer Description)
    break&&continue
    C++解析六-继承
    C++解析五-this 指针,指向类的指针
    1-find
    C++解析四-友员函数、内联函数、静态成员
    树形结构节点求和,以及set排序
    java.util.ConcurrentModificationException 解决和for循环时对集合remove操作
    eclipse保存卡死和内存溢出
    关于Eclipse安装了反编译插件,无法查看源码问题
  • 原文地址:https://www.cnblogs.com/hlmark/p/4001142.html
Copyright © 2011-2022 走看看