Beavergnaw
Time Limit:1s | Memory limit:32M |
Accepted Submit:437 | Total Submit:765 |
When chomping a tree the beaver cuts a very specific shape out of the tree trunk. What is left in the tree trunk looks like two frustums of a cone joined by a cylinder with the diameter the same as its height. A very curious beaver tries not to demolish a tree but rather sort out what should be the diameter of the cylinder joining the frustums such that he chomped out certain amount of wood. You are to help him to do the calculations.
We will consider an idealized beaver chomping an idealized tree. Let us assume that the tree trunk is a cylinder of diameter D and that the beaver chomps on a segment of the trunk also of height D. What should be the diameter d of the inner cylinder such that the beaver chmped out V cubic units of wood? Input contains multiple cases each presented on a separate line. Each line contains two integer numbers D and V separated by whitespace. D is the linear units and V is in cubic units. V will not exceed the maximum volume of wood that the beaver can chomp. A line with D=0 and V=0 follows the last case. For each case, one line of output should be produced containing one number rounded to three fractional digits giving the value of d measured in linear units. Sample input 10 250 20 2500 25 7000 50 50000 0 0 Sample Output 8.054 14.775 13.115 30.901 |
解题:
圆台体积V与大直径D小直径d直径之间的关系为:V=PI*(D*D*D-d*d*d)/6
控制输出精度,需要包含的头文件 #include <iomanip>
setprecision(n)设置精度为n,当没有设置fixed时,这个数的精度为n,设置fixed时,小数点后的数字精度为n,小数点前没有限制。