Recent Posts
Notice
No Rules Rules
어린 왕자 (feat. 백준, 1004번) 본문
728x90
반응형
어린 왕자
https://www.acmicpc.net/problem/1004
1004번: 어린 왕자
입력의 첫 줄에는 테스트 케이스의 개수 T가 주어진다. 그 다음 줄부터 각각의 테스트케이스에 대해 첫째 줄에 출발점 (x1, y1)과 도착점 (x2, y2)이 주어진다. 두 번째 줄에는 행성계의 개수 n이 주
www.acmicpc.net
반응형
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
register int T;
cin >> T;
for (register int i = 0, x1, y1, x2, y2, n, count, j, cx, cy, r, d, t1, t2; i < T; ++i) {
cin >> x1 >> y1 >> x2 >> y2 >> n;
count = 0;
for (j = 0; j < n; ++j) {
cin >> cx >> cy >> r;
d = (cx - x1) * (cx - x1) + (cy - y1) * (cy - y1);
t1 = d > r * r ? false : true;
d = (cx - x2) * (cx - x2) + (cy - y2) * (cy - y2);
t2 = d > r * r ? false : true;
if (t1 != t2)
count++;
}
cout << count << "\n";
}
return 0;
}
// *&)*@*
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
숫자의 합 (feat. 백준, 11720번) (0) | 2022.08.11 |
---|---|
아스키 코드 (feat. 백준, 11654번) (0) | 2022.08.11 |
한수 (feat. 백준, 1065번) (0) | 2022.08.10 |
셀프 넘버 (feat. 백준, 4673번) (0) | 2022.08.10 |
정수 N개의 합 (feat. 백준, 15596번) (0) | 2022.08.10 |
Comments