Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
Problem Statement
Given three integers $a$, $b$, and $c$, output Yes
if $\sqrt a + \sqrt b < \sqrt c$ holds, otherwise output No
.
Examples
Sample Input #1
|
|
Sample Output #1
|
|
$\sqrt 2 + \sqrt 3 < \sqrt 9$ does not hold.
Sample Input #2
|
|
Sample Output #2
|
|
$\sqrt 2 + \sqrt 3 < \sqrt 10$ holds.
Analysis
Incorrect Approach
Directly using the system’s sqrt
function with floating-point precision errors will result in wrong answers:
|
|
This approach requires special handling to avoid precision issues!
Correct Approach
Derivation steps:
$\sqrt a + \sqrt b < \sqrt c$
$(\sqrt a + \sqrt b)^2 < (\sqrt c)^2$
$a + b + 2\sqrt{ab} < c$
$2\sqrt{ab} < c - a - b$
$(2\sqrt{ab})^2 < (c - a - b)^2$
$4ab < (c - a - b)^2$
Note: An additional case occurs when $c - a - b < 0$ (i.e., $c < a + b$), which should directly output No
. Failure to consider this will result in WA, as $(c - a - b)^2$ ignores negative values!
Solution Code
|
|