1.

/**
* FWP, Angewandte Mathematik, SS11
* Problem: 10297 - Beavergnaw
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1238
*
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-04-21 22:33:39
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.128
*/

import java.io.*;
import java.util.*;


public class Main
{
/**Rounds a double value to given precision.
*
* @param d The Value to round.
* @param precision Number of digits after point.
* @return Rounded value.
*/
static double roundDouble(double d, int precision)
{
double n = Math.pow(10, precision);
return (Math.floor(d * n + 0.5) / n);
}
/**Returns the diameter (d) of the small cylinder not chomped by the beaver.
*
* Mathematical background:
* Volume cylinder: V = r^2 * pi * h = (D/2)^2 * pi * D = 1/4 * D^3 * pi
* Volume cone : V = 1/3 * r^2 * pi * h = 1/24 * D^3 * pi
* Volume max chomped out (d = 0): V = 1/4 * D^3 * pi - 2 * 1/24 * D^3 * pi = 1/6 * D^3 * pi
* V(d) = 1/6 * pi * (D^3 - d^3)
* d(V) = 3droot(D^3 - 6 * V / pi) <--- the formula we use here
*
* @param D Diameter and height of the tree.
* @param V Volume the beaver chomped out.
* @return d
*/
static double getSmallD(double D, double V)
{
return Math.pow((Math.pow(D, 3.0) - (6.0 * V) / Math.PI), 1.0 / 3.0);
}

public static void main(String args[]) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
double D = Double.parseDouble(tokenizer.nextToken());
double V = Double.parseDouble(tokenizer.nextToken());
while(D != 0 || V != 0)
{
// always print 3 digits behind number for acc
System.out.printf("%.3f\n", roundDouble(getSmallD(D, V), 3));
tokenizer = new StringTokenizer(reader.readLine());
D = Integer.parseInt(tokenizer.nextToken());
V = Integer.parseInt(tokenizer.nextToken());
}

}

}

-------------------------------------------------------


1.
/*
* ACM Contest training
* Problem: 10297 - Beavergnaw
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1238
*
* @author Patrick Bedat, Philippe Brousse, Christoph Goettschkes
* @version 1.0, 11/14/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.088
*/

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.*;

import java.math.BigInteger;

class Main {

static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

public static void main(String[] agrs) throws IOException {
int D, V;

do {
String[] in = reader.readLine().split(" ");
D = Integer.parseInt(in[0]);
V = Integer.parseInt(in[1]);
if(D == 0 && V == 0)
return;

double temp = (D*D*D*(Math.PI*2./3)-4*V)/(Math.PI*2./3);

//dritte Wurzel
double d = Math.pow(temp, 1./3);


System.out.printf("%.3f%n",d);
} while (true);
}
}