No Rules Rules

어린 왕자 (feat. 백준, 1004번) 본문

생활/코테

어린 왕자 (feat. 백준, 1004번)

개발하는 완두콩 2022. 8. 10. 22:22
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
반응형
Comments