Problem Link: contest, practice
Difficulty: Cakewalk
Pre-requisites: Geometry, Implementation
Problem:
We are given two numbers A and B. Our task is to determine the minimal and the maximal possible value of number C thus exists a non-obtuse triangle with the lengths of the sides equal to A, B and C.
It’s also guaranteed, that A < B.
Explanation:
It was the easiest problem of the contest.
Since A < B, the only angles, that could be obtuse, are the angles between sides A and B or A and C.
So, the minimal possible value of C is reached when the angle between sides A and C is right(equals to 90 degrees).
Also, the maximal possible value of C is reached when the angle between sides A and B is right(equals to 90 degrees).
The first value Cmin = sqrt( B2 - A2 );
The second value Cmax = sqrt( B2 + A2 ).
The total complexity is O(1) per testcase.
Setter’s Solution: link
Tester’s Solution: link