Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- MariaDB
- github
- isNotEmpty
- IntelliJ
- pem
- iBatis
- java
- spring
- Javascript
- 티스토리챌린지
- mysql
- Kibana
- 리눅스
- git
- analytics4
- DBMS
- springboot
- Python
- PostgreSQL
- Linux
- 자바
- mssql
- pandas
- 호이스팅
- 명령어
- docker
- oracle
- 404error
- 오블완
- SQL
Archives
- Today
- Total
hanker
백준(1002) JAVA - 터렛 본문
반응형
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 |