2015
09-18

# Skycity

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?

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.

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.

50 10 800 120 5
300 50 2000 500 10

149968.308
2196020.459

Skycity

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

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 requirment 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?

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi=acos(-1);
int R,r,H,t,S;
double getlen(int n,double r)
{
return 2.0*r*tan(pi/n);
}
int main()
{
//freopen("dd.txt","r",stdin);
while(scanf("%d%d%d%d%d",&R,&r,&H,&t,&S)!=EOF)
{
double h=(double)H/t,ans=0;
int limit=100000;
for(int i=t;i>=1;i--)
{
double rr=1.0*(R-r)/t*(i-1)+r;
int mi=3,ma=limit,mid,num;
double s;
while(mi<=ma)
{
mid=(mi+ma)>>1;
double tmp=getlen(mid,rr)*h;
if(tmp-S>1e-8)
{
s=tmp;
num=mid;
mi=mid+1;
}
else
ma=mid-1;
}
ans+=num*s;
limit=num;
}
printf("%.3lf\n",ans);
}
return 0;
}