Problem Statement
Problem Description
Given a circle defined by its center (cx, cy) and radius r, determine the position of a point (px, py) relative to the circle. The point can be either Inside, On, or Outside the circle.
To avoid using the square root function, compare the squared distance from the point to the center of the circle with the square of the radius:
- If
(px - cx)² + (py - cy)² < r², the point is Inside. - If
(px - cx)² + (py - cy)² = r², the point is On. - If
(px - cx)² + (py - cy)² > r², the point is Outside.
Examples
- Input:
0 0 5 3 4→ Output:On - Input:
1 1 2 2 3→ Output:Outside
These examples illustrate how to compute the squared distance and compare it to the squared radius.