Problem K: Cylinder
来源:互联网 发布:windows nginx 下载 编辑:程序博客网 时间:2024/05/01 00:07
Problem K: Cylinder
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 17 Solved: 7
[Submit][Status][Web Board]
Description
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?
Input
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.
Output
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.
Sample Input
10 1010 5010 300 0
Sample Output
54.247785.398412.095
HINT
这一题的主要意思就是给你一张纸,让你剪成两半,一张留着做底一张留着做身,问这个圆筒最大的容积!
注意精度问题就可以了!不注意WA不知道原因
#include<stdio.h>#define PI 3.141592653589double area(double x,double y){//以x为园的周长double r,s,v;r=x/(PI*2);s=PI*r*r;v=s*(y-x/PI);return v; }int main(){double w,h,v1,v2,r,r1,s;while(scanf("%lf%lf",&w,&h)&&(w||h)){//x为圆的高r1=h/(PI+1)/2;if(r1>w/2){r=w/2;}else{r=r1;}s=PI*r*r;v1=s*w;v2=area(w,h); if(v1>v2){printf("%.3lf\n",v1);}else{printf("%.3lf\n",v2);}}}
- Problem K: Cylinder
- ZOJ Problem Set - 3866 Cylinder Candy
- Cylinder
- Problem K
- Problem K
- Problem K
- Problem K
- Problem K
- Problem K
- Problem-K
- Problem K
- Problem K
- Problem K
- Problem K
- Problem-K
- Problem K
- problem k
- 1010 Problem K
- 常用开发工具的密钥收藏
- 线段树总结
- leetcode_25_Reverse Nodes in k-Group
- Perl 懒惰匹配
- SHOI 2014 全
- Problem K: Cylinder
- 我为什么要求你用功读书
- [Android] ListView 滚回顶部
- leetcode_138_ Copy List with Random Pointer
- 数据结构之栈
- HTTP协议与XML
- Xcode提交代码到SVN,文件右边出现UM
- 博白县办港澳通行证流程及相关费用
- leetcode_141_ Linked List Cycle