-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_1002.java
More file actions
65 lines (59 loc) ยท 1.71 KB
/
_1002.java
File metadata and controls
65 lines (59 loc) ยท 1.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package backjoon;
// https://www.acmicpc.net/problem/1002
// ํฐ๋
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class _1002 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// memory 11840 runtime 96
int caseCnt = Integer.parseInt(br.readLine());
for(int i=0; i<caseCnt; i++){
StringTokenizer st = new StringTokenizer(br.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());
// ๋์ ๊ฐ ๊ฑฐ๋ฆฌ distance์ ์ ๊ณฑ
int distance_pow = (int)(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
// ์์ด ํ๋๊ณ ๋ฐ์ง๋ฆ์ด ๊ฐ์ ๊ฒฝ์ฐ => ๋ฌดํ๋
if(x1 == x2 && y1 == y2 && r1 == r2) {
System.out.println(-1);
}
// ๋ ์์ด ๋ง๋์ง ์์๋
else if(distance_pow > Math.pow(r1 + r2, 2)) {
System.out.println(0);
}
// ์ ์์ ์์ด ์์ผ๋ ๋ด์ ํ์ง ์์ ๋
else if(distance_pow < Math.pow(r2 - r1, 2)) {
System.out.println(0);
}
// ๋ด์
else if(distance_pow == Math.pow(r2 - r1, 2)) {
System.out.println(1);
}
// ์ธ์
else if(distance_pow == Math.pow(r1 + r2, 2)) {
System.out.println(1);
}
else {
System.out.println(2);
}
}
}
}
/*
input
3
0 0 13 40 0 37
0 0 3 0 7 4
1 1 1 1 1 5
output
2
1
0
*/