Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fi first
- #define se second
- #define eps 1e-9
- #define eq(a, b) (a == b)
- #define lt(a, b) (a < b)
- using namespace std;
- using i64 = long long;
- using ld = float;
- ld a, b, c, d;
- ld get_hx(ld x) {
- return max(
- x * x + a * x + b,
- x * x + c * x + d
- );
- }
- int main() {
- cin.tie(0)->sync_with_stdio(0);
- cin >> a >> b >> c >> d;
- if (eq(a, c)) {
- ld x = (ld)-a/2;
- if (lt(get_hx(-c/2), get_hx(x))) x = -c/2;
- cout << x << ' ' << get_hx(x) << '\n';
- return 0;
- }
- ld x = (ld)(d - b) / (a - c);
- if (lt(get_hx(-a/2), get_hx(x))) {
- x = (ld)-a/2;
- }
- if (lt(get_hx(-c/2), get_hx(x))) {
- x = (ld)-c/2;
- }
- cout << x << ' ' << get_hx(x) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment