{"raw_statement":[{"iden":"statement","content":"You're testing out a catapult that you built for POE class, and you're trying to get it to launch an eraser over a wall.\n\nThe catapult launches the eraser $a$ meters away from the wall, and you're trying to get the catapult to hit a target $b$ feet above the ground, and $c$ meters away from the wall in the exact opposite direction.\n\nThe wall is $d$ meters high, and it is very thin (assume it has no thickness).\n\nGiven this information, figure out the minimum possible maximum height of the eraser, such that the eraser still clears the wall. In other words, among all eraser trajectories that hit the target and successfully clear the wall, find the lowest possible maximum height of the eraser.\n\nAssume that you launch the device in a vacuum (i.e. there is no air resistance).\n\nThe only line of input contains 4 space-separated positive integers: $a$, $b$, $c$, and $d$, as described above. $b$ is guaranteed to be less than $d$.\n\nOutput a single positive integer $h$: the maximum height of the eraser, if you launch it so that it hits the target and clears the wall, and has the minimum possible maximum height.\n\nYou don't need to use any physics equations to solve this problem. You can solve it using only algebra.\n\nAlso, your answers don't have to be exactly equal to ours. As long as they're within a few decimal places, your solution will be judged as correct.\n\n"},{"iden":"input","content":"The only line of input contains 4 space-separated positive integers: $a$, $b$, $c$, and $d$, as described above. $b$ is guaranteed to be less than $d$."},{"iden":"output","content":"Output a single positive integer $h$: the maximum height of the eraser, if you launch it so that it hits the target and clears the wall, and has the minimum possible maximum height."},{"iden":"examples","content":"Input5 0 5 7\nOutput7.0000000000000195\nInput5 0 9 7\nOutput7.62222191701435\nInput5 6 1 12\nOutput15.778572363190715\n"},{"iden":"note","content":"You don't need to use any physics equations to solve this problem. You can solve it using only algebra.Also, your answers don't have to be exactly equal to ours. As long as they're within a few decimal places, your solution will be judged as correct."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"Let $ a, c, d \\in \\mathbb{R}^+ $ be horizontal distances (in meters), and $ b, d \\in \\mathbb{R}^+ $ be vertical heights (in feet, but unit consistency assumed), with $ b < d $.\n\nDefine the launch point at $ (0, 0) $, the wall at $ x = a $ with height $ d $, and the target at $ x = a + c $ with height $ b $.\n\nAssume the eraser follows a parabolic trajectory:  \n$ y(x) = px(1 - \\frac{x}{a+c}) $, or equivalently, a quadratic passing through $ (0,0) $ and $ (a+c, b) $.\n\nWe seek the **minimum possible maximum height** $ h $ of such a parabola that satisfies $ y(a) \\geq d $.\n\nLet the trajectory be:  \n$ y(x) = kx(a + c - x) $, normalized to pass through $ (a+c, b) $:  \nThen $ b = k(a+c)c \\Rightarrow k = \\frac{b}{c(a+c)} $.\n\nSo:  \n$ y(x) = \\frac{b}{c(a+c)} x(a + c - x) $\n\nThe maximum height occurs at vertex $ x = \\frac{a+c}{2} $:  \n$ h = y\\left( \\frac{a+c}{2} \\right) = \\frac{b}{c(a+c)} \\cdot \\frac{a+c}{2} \\cdot \\frac{a+c}{2} = \\frac{b(a+c)}{4c} $\n\nBut we must enforce $ y(a) \\geq d $:  \n$ y(a) = \\frac{b}{c(a+c)} \\cdot a \\cdot (a + c - a) = \\frac{b}{c(a+c)} \\cdot a \\cdot c = \\frac{ab}{a+c} \\geq d $\n\nThis constraint $ \\frac{ab}{a+c} \\geq d $ is **not** satisfied in general (and is given that $ b < d $, so likely violated).\n\nThus, the **unconstrained** parabola through $ (0,0) $ and $ (a+c, b) $ does **not** clear the wall.\n\nWe must find the **lowest** parabola passing through $ (0,0) $ and $ (a+c, b) $, and tangent to the line $ y = d $ at $ x = a $ — i.e., the minimal maximum height trajectory that **just clears** the wall.\n\nSo impose:  \n1. $ y(0) = 0 $  \n2. $ y(a+c) = b $  \n3. $ y(a) = d $  \n4. $ y'(a) = 0 $ (tangent at wall — minimal max height)\n\nLet $ y(x) = px^2 + qx $\n\nConditions:  \n- $ y(0) = 0 $ → satisfied  \n- $ y(a+c) = p(a+c)^2 + q(a+c) = b $  \n- $ y(a) = pa^2 + qa = d $  \n- $ y'(x) = 2px + q \\Rightarrow y'(a) = 2pa + q = 0 \\Rightarrow q = -2pa $\n\nSubstitute $ q = -2pa $ into $ y(a) = d $:  \n$ pa^2 - 2pa^2 = d \\Rightarrow -pa^2 = d \\Rightarrow p = -\\frac{d}{a^2} $\n\nThen $ q = -2p a = \\frac{2d}{a} $\n\nNow plug into $ y(a+c) = b $:  \n$ p(a+c)^2 + q(a+c) = b $  \n$ -\\frac{d}{a^2}(a+c)^2 + \\frac{2d}{a}(a+c) = b $\n\nFactor $ d(a+c)/a $:  \n$ d(a+c) \\left( -\\frac{a+c}{a^2} + \\frac{2}{a} \\right) = b $  \n$ d(a+c) \\left( \\frac{ - (a+c) + 2a }{a^2} \\right) = b $  \n$ d(a+c) \\left( \\frac{ a - c }{a^2} \\right) = b $\n\nSo:  \n$ d(a+c)(a - c) = a^2 b $  \n→ $ d(a^2 - c^2) = a^2 b $\n\nBut this is a **constraint** that must hold — yet in general it does not. So we **cannot** assume tangency unless this holds.\n\nBut we are told: “find the minimum possible maximum height such that the eraser clears the wall and hits the target”.\n\nSo we must find the **parabola** through $ (0,0) $ and $ (a+c, b) $, with **minimum apex height**, subject to $ y(a) \\geq d $.\n\nLet the general parabola:  \n$ y(x) = kx(a+c - x) $, as before → apex at $ x = \\frac{a+c}{2} $, height $ h = \\frac{k(a+c)^2}{4} $\n\nConstraint: $ y(a) = k a c \\geq d \\Rightarrow k \\geq \\frac{d}{ac} $\n\nMinimize $ h = \\frac{k(a+c)^2}{4} \\Rightarrow $ minimize $ k $, so set $ k = \\frac{d}{ac} $\n\nThen:  \n$ h = \\frac{d}{ac} \\cdot \\frac{(a+c)^2}{4} = \\frac{d(a+c)^2}{4ac} $\n\n**Thus, the minimal possible maximum height is:**  \n$$\n\\boxed{h = \\frac{d(a + c)^2}{4ac}}\n$$","simple_statement":"Find the minimum possible maximum height of a projectile that launches from a point, clears a wall of height d at distance a, and lands at a target of height b at distance a+c on the other side.","has_page_source":false}