#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;
}

 

원을 두 개 그려서 '어떻게', '어디서' 만나는지의 여부를 따져보면 된다.

 

문제:https://www.acmicpc.net/problem/1002

 

1002번: 터렛

각 테스트 케이스마다 류재명이 있을 수 있는 위치의 수를 출력한다. 만약 류재명이 있을 수 있는 위치의 개수가 무한대일 경우에는 $-1$ 출력한다.

www.acmicpc.net

'Baekjoon > C++' 카테고리의 다른 글

[백준 1010번] 다리 놓기  (0) 2023.07.24
[백준 1003번] 피보나치 함수  (0) 2023.07.21
[백준 2563번] 색종이  (0) 2023.07.19
[백준 10798번] 세로읽기  (0) 2023.07.04
[백준 2566번] 최댓값  (0) 2023.05.23

+ Recent posts