【蓝桥杯】题目 1111: Cylinder

题目 1111: Cylinder

时间限制: 1Sec 内存限制: 128MB

题目描述
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

刷题地址

题意:

  • 已知矩形的宽w,高h,用剪刀裁剪成两部分,一部分用作圆柱体的底面圆,一部分用作圆柱体的柱身,求圆柱体最大的体积是多少?

思路:

  • 首先需要取一下π的值,从百度搜索了一个求100位圆周率的代码,然而看不懂,暂时放着,以后慢慢研究
  • 题解参考,叙述详细清楚,在此进行转述
  • 由题目意思,分成两种情况分析:
  • 在这里插入图片描述
  • ① h-2r为圆的周长
    有 2πr ≤ h-2r
    r ≤ h / 2(π+1)
    v = π r² w
  • ② w为圆的周长
    有 2πr ≤ w
    r ≤ w / 2π
    v = π r² (h-2r)

踩坑:

  • 题目中给的w和h都是整数,很容易
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值