HDU 4798 Skycity (计算几何+推公式) 2013 Asia Changsha Regional Contest

来源:互联网 发布:微信竞猜游戏源码 编辑:程序博客网 时间:2024/06/10 01:07

传送门

Skycity

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


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

题目大意:

给出一个圆台,给出底部半径 R 和顶部半径 r ,圆台高度为 H,把圆台分成 F 份等高的小圆台,按每个圆台顶部的圆为标准,用多边形来

围住这些圆,并且给出每块矩形的最小面积 S,所以有它们的面积,它们的面积就是它们的耗费。问要求的最小耗费是多少。

解题思路:

根据题意很明显可以推出来,一定是当围成的多边形是正多边形的时候才可以,然后在 yy 一下就 OK 了,但是一定要注意精度问题。

My Code

/**2016 - 09 - 23 晚上Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const LL INF = 1e17+5;const int MAXN = 1e6+5;const int MOD = 1e9+7;const double eps = 1e-8;const double PI = acos(-1.0);using namespace std;int main(){    double R, r, H, F, S;    while(cin>>R>>r>>H>>F>>S)    {        double h = H / F;        double k = S / h;        double tmp = (R-r)/F;        double sum = 0, i = r;        for(int i=0; i<F; i++)        {            double RRR = r + i*tmp;            int n = (int)(PI/atan(k/(2.0*RRR)));            double tp = tan(PI/(1.0*n))*RRR*2;            sum += n*tp*h;        }        printf("%.3lf\n",sum);    }    return 0;}
0 0