Problem Links:
poj2405,
Problem:
Beavergnaw
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 4956 | Accepted: 3342 |
Description


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
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.
Output
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
Source
Waterloo local 2002.07.01
Solution:
Math.
Source Code:
//Mon Apr 19 11:17:52 CDT 2010#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define Pi 3.1415926
using namespace std;
int main( int argc, const char* argv[] )
{
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
double D;
double d;
double V;
while(cin >> D >> V && V)
{
d = pow(D*D*D-6*V/Pi,1.0/3);
cout.precision(3);
cout << fixed << d << endl;
}
// fclose(stdin);
// fclose(stdout);
return 0;
}
No comments :
Post a Comment