-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCirclesIntersection.cpp
More file actions
79 lines (68 loc) · 1.66 KB
/
CirclesIntersection.cpp
File metadata and controls
79 lines (68 loc) · 1.66 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Aizu 0023
* Created by Ziyi Tang
* Basic Geometry (Circle)
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
#define INF (int)1E9
#define INFL (long)1E18
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int main(){
int test;
cin >> test;
while(test--){
double x1,y1,r1,x2,y2,r2;
cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
double up1 = y1+r1;
double down1 = y1-r1;
double left1 = x1-r1;
double right1 = x1+r1;
double up2 = y2+r2;
double down2 = y2-r2;
double left2 = x2-r2;
double right2 = x2+r2;
int flag = -10;
if ((left1 > left2 && right1 < right2 && up1 < up2 && down1 > down2) ||
(left1 > left2 && right1 < right2 && up1 < up2 && down1 > down2) ||
(left1 > left2 && right1 < right2 && up1 < up2 && down1 > down2) ||
(left1 > left2 && right1 < right2 && up1 < up2 && down1 > down2)){
flag = -2;
}
if ((left1 < left2 && right1 > right2 && up1 > up2 && down1 < down2) ||
(left1 < left2 && right1 > right2 && up1 > up2 && down1 < down2) ||
(left1 < left2 && right1 > right2 && up1 > up2 && down1 < down2) ||
(left1 < left2 && right1 > right2 && up1 > up2 && down1 < down2)){
flag = 2;
}
if (flag == -10){
double dis = -1 ;
dis = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
if (dis > r1+r2){
flag = 0;
}
else{
flag = 1;
}
}
cout << flag << endl;
}
return 0;
}