这不仅仅是数学问题。
有以下Java代码:
oaidl::VARIANT {
n1: oaidl::VARIANT_n1 {
0: [0, 0, 0]
}
}
我的问题是,我如何找出import java.util.Arrays;
import java.util.Random;
public class MainClazz {
public static boolean prove(double[] maxs, double[] currents) {
double sum = 0;
boolean b = true;
for (int i = 0; i < maxs.length; i++) {
sum += currents[i];
if (100.0 / maxs[i] * currents[i] < 42.0) {
b = false;
}
}
if (sum >= 100.0 || (sum >= 50.0 && b)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
final int n = 5;
double d = 40.0; // How i have to choose d?
double[] maxs = new double[n];
Arrays.fill(maxs, d);
double[] currents = new double[n];
Random rand = new Random();
int sum = 0;
for (int i = 0; i < 10000; i++) {
for (int j = 0; j < n; j++) {
currents[j] = rand.nextDouble() * d; // Expectation value: d/2.0
}
if (prove(maxs, currents)) {
sum++;
}
}
System.out.println(sum / 10000.0);
}
}
的值,以便程序在方法结束时打印出d
。
我的尝试:
0.5
但是那还是有问题的。非常感谢您的帮助和支持。 :)