728x90
https://www.acmicpc.net/problem/1002
1002번: 터렛
각 테스트 케이스마다 류재명이 있을 수 있는 위치의 수를 출력한다. 만약 류재명이 있을 수 있는 위치의 개수가 무한대일 경우에는 -1을 출력한다.
www.acmicpc.net
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int testCase;
cin >> testCase;
for (int t = 0; t < testCase; t++) {
int x1, y1, r1, x2, y2, r2;
cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
double distance = pow(x1 - x2, 2) + pow(y1 - y2, 2);
if (x1 == x2 && y1 == y2 && r1 == r2/*같은 원*/)
cout << -1 << '\n';
else if ((x1 == x2 && y1 == y2 && r1 != r2)/*동심원*/ || distance < pow(r1 - r2, 2)/*외부*/ || pow(r1 + r2, 2) < distance/*내부*/)
cout << 0 << '\n';
else if (pow(r1 + r2, 2) == distance/*외접*/ || pow(r1 - r2, 2) == distance/*내접*/)
cout << 1 << '\n';
else
cout << 2 << '\n';
}
return 0;
}
728x90
'알고리즘 문제' 카테고리의 다른 글
[백준] 2309번 일곱 난쟁이 (0) | 2020.03.07 |
---|---|
[백준] 3053번 택시 기하학 (0) | 2020.03.07 |
[백준] 5543번 상근날드 (0) | 2020.03.07 |
[백준] 2206번 벽 부수고 이동하기 (0) | 2020.03.03 |
[백준] 11816번 8진수, 10진수, 16진수 (0) | 2020.03.03 |