import java.lang.reflect.Method;
import java.util.concurrent.ThreadLocalRandom;

public class TemplateFFFFFFFF {

    public TemplateFFFFFFFF() {
    }

    public double method0(int depth, double result) throws Exception {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        return result + Math.sqrt(random.nextInt(1000)) + rollDice(depth, result);
    }

    public double method1(int depth, double result) throws Exception {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        return result + Math.pow(random.nextDouble(10.0), random.nextDouble(10.0)) + rollDice(depth, result);
    }

    public double method2(int depth, double result) throws Exception {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        return result + random.nextDouble(1000.0) + rollDice(depth, result);
    }

    public double rollDice(int depth, double result) throws Exception {
        if (depth == 0) {
            return result;
        } else {
            int index = ThreadLocalRandom.current().nextInt(3);;
            Method methodToCall = this.getClass().getMethod("method" + index, int.class, double.class);
            return (double) methodToCall.invoke(this, depth - 1, result);
        }
    }

    public double workFFFFFFFF(int depth) throws Exception {
        return rollDice(depth, 0.0);
    }
}