1001.赶火车

到达每个ab的值的概率是相等的 都是1/(m+n)
听说hdu4586差不多的题
数学期望,Ex=n/(m+n)
正确的之和+m/(m+n)*(错误的之和+Ex)
https://blog.csdn.net/xuxiaobo1234/article/details/89228118(上面公式化简结果一致)

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int x = sc.nextInt();
			while (x-- > 0) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				int y = sc.nextInt();
				double sum = 0;
 				for (int i = 0; i < n; i++) {
					sum += sc.nextInt();
				}
				double res1 = sum / (m + n);
 				sum = 0;
				for (int i = 0; i < m; i++) {
					sum += sc.nextInt();
				}
				double res2 = sum / (m + n);
				double res = (res1 + res2) / (1 - (m * 1.0) / (m + n));
				if (res <= y)
					System.out.println("Go");
				else
					System.out.println("Wait");
			}
		}
	}
}
原文地址:https://www.cnblogs.com/cznczai/p/11150038.html