Untitled
unknown
c_cpp
a year ago
1.1 kB
3
Indexable
#include <bits/stdc++.h> using namespace std; double px[20], py[20]; double d, g = 1.0, pi = acos(-1.0); int n, b; bool possible(double v, double R) { if(v * v < R * g) return 0; double theta = 0.5 * asin(R * g / (v * v)); theta = max(pi/2 - theta, theta); for(int i = 0; i < n; i++) { double x = px[i] - floor(px[i]/R) * R; double y = x * tan(theta) - g * x * x/(2.0*v*v*cos(theta)*cos(theta)); if(y < py[i]) return 0; } return 1; } int main() { cin >> d >> n >> b; b++; for(int i = 0; i < n; i++) cin >> px[i] >> py[i]; double ans = 2e9+10; for(int bounce = 1; bounce <= b; bounce++) { double R = d/bounce; double anshere = 2e9+15; double lo = 0, hi = 2e5; while((hi - lo) > 0.0000001) { double mid = (lo + hi) / 2; if(possible(mid, R)) { anshere = mid; hi = mid; } else lo = mid; } ans = min(ans, anshere); } cout << fixed << setprecision(10) << ans << endl; return 0; }
Editor is loading...
Leave a Comment