-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturret1002.java
More file actions
47 lines (41 loc) · 1.38 KB
/
Copy pathturret1002.java
File metadata and controls
47 lines (41 loc) · 1.38 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class turret1002 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-->0){
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());
System.out.println(marin_point(x1,y1,r1,x2,y2,r2));
}
}
public static int marin_point(int x1,int y1,int r1,int x2,int y2,int r2) {
int r = (int)(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2));
if(x1==x2&&y1==y2&&r1==r2){
return -1;
}
else if(r==Math.pow(r2+r1,2)){
return 1;
}
else if(r==Math.pow(r2-r1, 2)){
return 1;
}
else if(r>Math.pow(r1+r2, 2)){
return 0;
}
else if(r < Math.pow(r2-r1, 2)){
return 0;
}
else{
return 2;
}
}
}