We all know that you can’t put a round peg in a square hole. Asking you to do so in this contest would be cruel and unusual punishment, which is banned by the Eighth Amendment to the United States Constitution. But, perhaps a more reasonable problem that the framers of the Constitution never thought about is determining if a given circle and square have an intersection of positive area (overlap), or touch (share a point in common), or don’t touch at all.
The framers of the US Constitution and the UCF Programming Team coaches would like to know, given a circle and a square, do the two overlap in some positive area, touch, or don’t touch at all. Help them out by writing a program to solve the problem!
Given the description of a square and circle in the Cartesian plane, determine if the intersection between the two has positive area (overlap), is a single point (touches) or doesn’t exist.
The first line of input contains three integers: x (-1,000 ≤ x ≤ 1,000), y (-1,000 ≤ x ≤ 1,000), and r (0 < r ≤ 1,000), representing the x and y coordinates and radius, respectively of the circle.
The second line of input contains three integers: tx (-1,000 ≤ tx < 1,000), ty (-1,000 ≤ ty < 1,000), and s (0 < s ≤ 1,000), where (tx, ty) represents the coordinates of the bottom left corner of the square and s represents the side length of the square. The square’s top right corner is (tx+s, ty+s), so that its sides are parallel to the x and y axes.
If the circle and square don’t touch, output 0 (zero). If they touch at a single point, output 1 (one). If they overlap in positive area, output 2 (two).