Editorial for Appleby Contest '20 P1 - Terrific Triangles


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: kdrkdr

Subtask 1

For the first subtask, there are only two types of triangles. Thus, it suffices to only check if the triangle is a right angle using the Pythagorean Theorem. If not, the triangle can only be obtuse.

Subtask 2

Notice that if the triangle is acute, a^2+b^2 > c^2 for hypotenuse c and side a, b; if the triangle is obtuse, a^2+b^2 < c^2.

The intuition comes from fixing the length of the two shorter sides. Starting from a right triangle, if the angle between a and b decreases, the length hypotenuse also decreases, and vice versa.

Using this fact, we can simply solve for the type of triangle by testing it against the aforementioned inequalities.


Comments

There are no comments at the moment.