Published easy solution to a problem with my future review half By the way underwater goo value
See this question, according to the meaning of the questions we will soon be able to find the time t c and d [i], the relationship between s [i], and then what?
Then will not the So I thought half-half enumeration answer, the answer so far has been close to the code annotated
#include <the iostream> #include <cstdio> #include <CString> the using namespace STD; Double D [ 100000 ], S [ 100000 ]; int n-, T; BOOL Check ( Double X) { Double SUM = 0 ; for (Register int I = . 1 ; I <= n-; I ++ ) { Double m = S [I] + X; // calculated velocity enumerated IF (m <= 0 ) return 0 ; // total rate is less than 0 it is impossible sum + = d [i] / m;// accumulated time } IF (SUM <= T) return . 1 ; // If the time is less than the total time, feasible the else return 0 ; } int main () { int I, J; the while (~ Scanf ( " % D% D " , & n-, & T)) { Double ANS; Double L = - 20000000 , R & lt = 20000000 ; // about enumeration section for (I = . 1 ; I <= n-; I ++ ) Scanf ( " %% LF LF",&d[i],&s[i]); for(i=1;i<=100;i++) { double mid=(l+r)/2; if(check(mid)){ ans=mid; r=mid;//如果答案可行,储存 } else l=mid; } printf("%.9lf\n",ans); } return 0; }