[BOJ / C++] 1002 터렛

Seulguo·2022년 7월 13일
0

Algorithm

목록 보기
51/185
post-thumbnail

🐣 문제

링크 : https://www.acmicpc.net/problem/1002


🐥 코드

#include <iostream>
using namespace std;

int main() {
	int num;
	int x1, y1, r1, x2, y2, r2;
	int d, cond1, cond2;
	cin >> num;

	for (int i = 0; i < num; i++) {
		cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
		d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
		cond1 = (r1 - r2) * (r1 - r2);
		cond2 = (r1 + r2) * (r1 + r2);

		if (d == 0) {
			if (cond1 == 0)
				cout << "-1" << endl;
			else
				cout << "0" << endl;
		}
		else if (d == cond1 || d == cond2)
			cout << "1" << endl;
		else if (cond1 < d && d < cond2)
			cout << "2" << endl;
		else
			cout << "0" << endl;
	}
}

0개의 댓글