2分探索
double f(vector<int> h, double g) { double sum = 0; for (int i = 0; i < h.size(); ++i) { sum += sqrt(2.0 * h[i] / g); } return sum; } class IncredibleMachineEasy { public: double gravitationalAcceleration(vector <int> H, int T) { double small = 1e-10; double large = 1e256; for (int loop = 10000; loop--; ) { double mid = (small + large) / 2.0; double t = f(H, mid); if (t >= T) small = mid; else large = mid; } return small; } };