아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Circle Meets Square

면접 대비

시간 제한1초메모리 제한1024 MB

요약
좌표축에 평행한 정사각형과 원이 주어질 때, 두 도형이 양의 넓이로 겹치는지, 한 점에서 만나는지, 만나지 않는지 판정한다.
난이도

보통10점 중 4점

유형
기하, 구현, 수학
정답자
아직 제출이 없습니다

문제

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).

힌트

Pictures of the Sample Input:

First SampleSecond SampleThird Sample

예제3

  1. 예제 1

    입력
    0 0 5
    2 3 1
    
    예상 출력
    2
    
  2. 예제 2

    입력
    0 0 5
    5 0 6
    
    예상 출력
    1
    
  3. 예제 3

    입력
    0 5 4
    -1 -1 1
    
    예상 출력
    0