题意
给出一个圆锥的表面积s(包括侧面和底面),求出该圆锥的最大体积v以及对应的高h和底面半径r。
数据范围的一些限定
1 <= s <= 10000
思路
假设圆锥母线长为L,则圆锥的侧面展开就是一个半径为L的扇形。
各种数学知识。。勾股定理啊,圆锥表面积、体积公式,求导,函数单调性与极值。。人老了怕忘,贴上来。。
以下是代码,各种多余头文件宏定义什么的请无视,在vimrc里写好了,懒得删掉了,可以视为我在装13。如果在其中发现有错误,请指出,发表此文部分原因是希望有人能够指出我可能存在的错误。
如果有人有更好的解法,请不吝赐教。
/*
* Author: Fiend
* Created Time: 2013/4/16 11:03:39
* File Name: test.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstddef>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#define ST size_type
#define PB push_back
#define LL long long
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::bitset;
using std::vector;
using std::pair;
using std::swap;
using std::sort;
using std::max;
using std::min;
const int inf = 0x3fffffff;
const double pi = atan(1) * 4;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<int>::iterator vit;
int main () {
double s, r, v, h, l;
while (cin >> s) {
r = sqrt (s / (4 * pi));
v = r * sqrt (s * s - 2 * pi * s * r * r) / 3;
l = (s - pi * r * r) / (pi * r);
h = sqrt (l * l - r * r);
printf("%.2f\n%.2f\n%.2f\n", v, h, r);
}
return 0;
}