hanker

백준(1002) JAVA - 터렛 본문

Study/ALGORITHM

백준(1002) JAVA - 터렛

hanker 2021. 7. 7. 11:44
반응형
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        for(int i = 0 ; i < n ; i++){
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int r1 = sc.nextInt();

            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            int r2 = sc.nextInt();

            int v = (int)(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));

            double plusR = Math.pow(r1 + r2, 2);
            double minusR = Math.pow(r2 - r1, 2);

            if(x1 == x2 && y1 == y2 && r1 == r2){
                System.out.println(-1);
            } else if(v > plusR || v < minusR) {
                System.out.println(0);
            } else if(v == minusR || v == plusR) {
                System.out.println(1);
            } else {
                System.out.println(2);
            }
        }
    }
}
반응형

'Study > ALGORITHM' 카테고리의 다른 글

백준(10870) JAVA - 피보나치 수 5  (0) 2021.08.17
백준(10872) JAVA - 팩토리얼  (0) 2021.07.09
백준(3053) JAVA - 택시 기하학  (0) 2021.07.07
백준(4153) JAVA - 직각삼각형  (0) 2021.06.29
백준(3009) JAVA - 네 번째 점  (0) 2021.06.29