Олимпиадный тренинг

Задача 38315. Triangle


An isosceles right triangle ABC with leg length d and point X are located on the coordinate plane. The legs of the triangle lie on the coordinate axes, and the vertices are located at points: A (0,0), B (d,0), C (0,d).

Write a program that determines the relative position of the point X and the triangle. If the point X is located inside or on the sides of the triangle, print 0. If the point is outside the triangle, print the number of the vertex closest to it.

Input
First, a natural number d (not exceeding 1000) is entered, and then the coordinates of the point X – two integers from ­–1000 to 1000.

Imprint
If the point lies inside, on the side of the triangle, or coincides with one of the vertices, then print the number 0. If the point lies outside the triangle, then print the number of the vertex of the triangle to which it is closest (1 – to vertex A, 2 – to B, 3 to C). If a point is located at the same distance from two vertices, print the vertex with the lower number.
Examples
# Input Output Explanation
1 5
1 1
0 The point lies inside the triangle.
2 3
-1 -1
1 The point lies outside the triangle and vertex A is closest to it
3 4
4 4
2 The point lies at an equal distance from vertices B and C, in this case, you need to print the vertex with the lower number, i.e. the number 2 should be displayed
4 4
2 2
0 The point lies on the side of the triangle.