Test instructions: A round table, the bottom and the top radius of r,r respectively, and then the height of H, a total f layer, the height of each layer, and then to the ceiling on each floor of the square glass, check glass to meet the following conditions:
The size of the square glass can not be less than s, and the lattice glass to be surrounded by a regular polygon, and just the ceiling around (that is, the round surface of the ceiling is the inner circle of the polygon), and to make the number of glass paste as small as possible, that is, the regular polygon of the number of sides to be as small as possible. Ask the total area of the last glass used.
Idea: Ask for the radius of each circle first, namely arithmetic progression. The second is the number of multilateral lines. Two points error-prone, the problem also has precision requirements .....
1#include <iostream>2#include <string.h>3#include <stdio.h>4#include <algorithm>5#include <cmath>6 using namespacestd;7 Const DoublePi=acos (-1);8 intr,r,h,t,s;9 DoubleH,ans;Ten Double Get(intNDoubler) { One return 2.0*r*tan (pi/n); A } - - voidbinary () { the intlimit=100000; - for(inti=t; i>=1; i--) { - DoubleRr=1.0* (r-r)/t* (i-1)+R; - intMi=3, ma=Limit,mid,num; + Doubles; - while(mi<=Ma) { +Mid= (MI+MA) >>1; A Doubletmp=Get(MID,RR) *h; at if(tmp-s>1e-8) { -s=tmp; -num=mid; -Mi=mid+1; -}Else -ma=mid-1; in } -ans+=num*s; tolimit=num; + } - } the * intMain () { $ while(~SCANF ("%d%d%d%d%d",&r,&r,&h,&t,&S)) {Panax NotoginsengH= (Double) h/t,ans=0; - binary (); theprintf"%.3lf\n", ans); + } A return 0; the}
View Code
ACM Regional race Changsha H Zoj 3733 (hdu 4798) Skycity