백준 1002번

이성준·2021년 11월 15일
0

알고리즘

목록 보기
2/13

백준 1002번

난이도 실버4

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws NumberFormatException, IOException {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(input.readLine());
    for(int i =0; i<n; i++){
      StringTokenizer st = new StringTokenizer(input.readLine());


      int x1 = Integer.parseInt(st.nextToken());
      int y1 = Integer.parseInt(st.nextToken());
      int r1 = Integer.parseInt(st.nextToken());
      int x2 = Integer.parseInt(st.nextToken());
      int y2 = Integer.parseInt(st.nextToken());
      int r2 = Integer.parseInt(st.nextToken());


    int distance = (int) (Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
    if((distance==0&&r1==r2)){
      System.out.println(-1);
    }
    else if(Math.pow(r1+r2,2)<distance||distance<Math.pow(r2-r1,2)||(distance==0&&r1!=r2)){
      System.out.println(0);
    }
    else if (Math.pow(r2 - r1,2) == distance || Math.pow(r2 + r1,2) == distance) {
      System.out.println(1);
      
    } 
 
    else{
      System.out.println(2);
    }
 

    }
    

  }

}

0개의 댓글