Baekjoon/C++
[백준 1002번] 터렛
Yo-mi
2023. 7. 21. 01:18
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, x1, x2, y1, y2, r1, r2, result;
bool in = true;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
if (x1 == x2 && y1 == y2 && r1 == r2) {
result = -1;
}
else if (sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) > r1 + r2)
result = 0;
else if (sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) == r1 + r2)
result = 1;
else if (sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) == abs(r1 - r2))
result = 1;
else if (sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) < abs(r1 - r2))
result = 0;
else
result = 2;
cout << result << endl;
in = true;
}
return 0;
}
원을 두 개 그려서 '어떻게', '어디서' 만나는지의 여부를 따져보면 된다.