数学题。设步行速度a,车速b,距离c。Teddy步行时间为T1,WhereIsHeroFrom步行时间T2,总时间T。若b>a:aT1 + b(T-T1) = c (1)aT2 + b(T-T2) = c (2)(1)-(2)得 a(T1-T2)-b(T1-T2) = 0。因为b>a 所以T1 = T2。即两人步行时间相等为T0。可假定Teddy先乘车T-T0,再步行T0;WhereIsHeroFrom步行T-T0+x = T0,x = 2T0-T。即为WhereIsHeroFrom与车的相遇时间。因此,可得方程(a+b) * (2T0-T) = (b-a) * (T-T0) (3)又因为aT0 + b(T-T0) = c (4)(3)与(4)联立,可解得T = ( C*(A+3B) ) / ( B*(3A+B) )若b
1 #include 2 3 int main() { 4 double a, b, c; 5 6 while (scanf("%lf %lf %lf", &a, &b, &c) != EOF) { 7 if (a > b) 8 a = c/a; 9 else 10 a = (c*(a+3.0*b))/(b*(3.0*a+b)); 11 printf("%.3lf\n", a); 12 } 13 14 return 0; 15 }
【HDOJ】2268 How To Use The Car,,
【HDOJ】2268 How To Use The Car