我是靠谱客的博主 唠叨薯片,这篇文章主要介绍1001: Cylinder,现在分享给大家,希望可以做个参考。

题目描述
Using a sheet of paper and scissors, you can cut out two faces to form a cylinder in the following way:

Cut the paper horizontally (parallel to the shorter side) to get two rectangular parts.

From the first part, cut out a circle of maximum radius. The circle will form the bottom of the cylinder.

Roll the second part up in such a way that it has a perimeter of equal length with the circle’s circumference, and attach one end of the roll to the circle. Note that the roll may have some overlapping parts in order to get the required length of the perimeter.

Given the dimensions of the sheet of paper, can you calculate the biggest possible volume of a cylinder which can be constructed using the procedure described above?

输入
The input consists of several test cases. Each test case consists of two numbers w and h (1 ≤ w ≤ h ≤ 100), which indicate the width and height of the sheet of paper.

The last test case is followed by a line containing two zeros.

输出
For each test case, print one line with the biggest possible volume of the cylinder. Round this number to 3 places after the decimal point.

样例输入:
10 10
10 50
10 30
0 0

样例输出:
54.247
785.398
412.095

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h> #define PI 3.141592653589793238 int main() { double w, h, r, result1, result2; while(scanf("%lf%lf", &w, &h) == 2 && w != 0) { r = w / (2 * PI); result1 = PI * r * r * (h - 2 * r); r = h / (2 * PI + 2); r = r * 2 > w ? w / 2 : r; result2 = PI * r * r * w; printf("%.3fn", result1>result2 ? result1:result2); } return 0; }

最后

以上就是唠叨薯片最近收集整理的关于1001: Cylinder的全部内容,更多相关1001:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部