-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1002.js
61 lines (53 loc) · 1.44 KB
/
1002.js
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
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
function main(input) {
const [T, ...testCases] = input;
testCases.forEach(testCase => {
let [x1, y1, r1, x2, y2, r2] = testCase.split(' ').map(_ => +_);
let distinct = Math.sqrt(Math.pow(Math.abs(x1 - x2), 2) + Math.pow(Math.abs(y1 - y2), 2));
if (distinct === 0) {
if (r1 === r2) {
console.log(-1);
return;
} else {
console.log(0);
return;
}
}
if(distinct < r1 || distinct < r2){
//내접
if(Math.abs(r1-r2) === distinct){
console.log(1);
return
}else if(distinct < Math.abs(r1-r2)){
console.log(0);
return
}else{
console.log(2);
return;
}
}else{
//외접
if (Math.abs(r1+r2) > distinct) {
console.log(2);
return;
} else if (Math.abs(r1+r2) === distinct) {
console.log(1);
return;
}else{
console.log(0);
return;
}
}
});
}