페이지

1004번: 어린 왕자

https://www.acmicpc.net/problem/1004


$O(nt)$

시작점과 끝점 중 하나만 포함하는 원 개수를 센다.


#include<stdio.h>
int x1, y1, x2, y2, n, t, res;
int main() {
    scanf("%d", &t);
    while (t--) {
        res = 0;
        scanf("%d %d %d %d %d", &x1, &y1, &x2, &y2, &n);
        for (int i = 0; i<n; i++) {
            int x, y, r;
            scanf("%d %d %d", &x, &y, &r);
            res += (x - x1)*(x - x1) + (y - y1)*(y - y1)<r*r ^ (x - x2)*(x - x2) + (y - y2)*(y - y2)<r*r;
        }
        printf("%d\n", res);
    }
    return 0;
}

댓글 없음 :

댓글 쓰기