-
Notifications
You must be signed in to change notification settings - Fork 0
/
1002.c
49 lines (45 loc) · 1.12 KB
/
1002.c
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
//
//
#include <stdio.h>
int main(void)
{
int cases;
long long x1, x2, y1, y2, r1, r2;
int result;
long long dSquare;
long long sum;
scanf("%lld", &cases);
for (int i = 0; i < cases; ++i) {
scanf("%lld%lld%lld%lld%lld%lld", &x1, &y1, &r1, &x2, &y2, &r2);
if ((x1 == x2) && (y1 == y2)) {
if (r1 == r2) {
result = -1;
}
else {
result = 0;
}
}
else {
dSquare = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
sum = r1 + r2;
if (dSquare == sum * sum) {
result = 1;
}
else if (dSquare > sum * sum) {
result = 0;
}
// distance < sum
else if (dSquare == r2 * r2 - 2 * r1 * r2 + r1 * r1) {
result = 1;
}
else if (dSquare < r2 * r2 - 2 * r1 * r2 + r1 * r1) {
result = 0;
}
else {
result = 2;
}
}
printf("%d\n", result);
}
return 0;
}