2018.03.29
[1002] 터렛
반응형
JAVA
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int c =sc.nextInt(),i;
for(i=0;i<c;i++) {
long x1=sc.nextLong(),y1=sc.nextLong(),r1=sc.nextLong(),x2=sc.nextLong(),y2=sc.nextLong(),r2=sc.nextLong();
long x=x2-x1,y=y2-y1,d=(x*x)+(y*y),r=r1+r2;
r*=r;
if(d==r) {
//반지름끼리 합하고 점과 점사이의 거리가 같을때 / 한점만 만난다.
System.out.println("1");
}else if(d>r) {
//반지름끼리 합이 점과 점사이의 거리보다 작을 때 / 교점이 없다.
System.out.println("0");
}else if(d<r) {
if(d==0) {
if(r1==r2) {
System.out.println("-1");
}else {
System.out.println("0");
}
}else {
long tmp=Math.abs(r2-r1)*Math.abs(r2-r1);
if(d==tmp) {
System.out.println("1");
}else if(d<tmp) {
System.out.println("0");
}else {
System.out.println("2");
}
}
}
}
sc.close();
}
}
반응형
'해본 것 > Baekjoon' 카테고리의 다른 글
[1003] 피보나치 함수 (0) | 2018.03.30 |
---|---|
[1001] A-B (0) | 2018.03.29 |
[1000] A+B (0) | 2018.03.29 |
다른 '해본 것/Baekjoon'의 최근 글