第二题我只过了30%,后面想想写了一下,应该没问题 public static double CalWater(int t, int m, int t1, int m1, int t2, int m2) { int enterWaterT = (t / (2 * t1)) * t1 + (Math.Min(t1, t % (2 * t1))); // 进水闸时长 int exitWaterT = (t / (2 * t2)) * t2 + (Math.Min(t2, t % (2 * t2))); // 出水阀时长 double enterWaterN = m1 * enterWaterT; double exitWaterN = m2 * exitWaterT; double result = Math.Max(0, Math.Min(m, enterWaterN - exitWaterN)); return result; }

相关推荐

牛客网
牛客企业服务