This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <math.h> | |
/** | |
* https://www.acmicpc.net/problem/1004 | |
* BOJ 백준온라인져지 1004 어린 왕자 풀이 | |
*/ | |
int main(){ | |
int T; | |
scanf("%d",&T); | |
while(T--){ | |
int x1,x2,y1,y2,result=0; | |
scanf("%d%d%d%d",&x1,&y1,&x2,&y2); | |
int N; | |
scanf("%d",&N); | |
while(N--){ | |
int cx,cy,r; | |
scanf("%d%d%d",&cx,&cy,&r); | |
double d1 = sqrt(pow(x1-cx,2)+pow(y1-cy,2)); | |
double d2 = sqrt(pow(x2-cx,2)+pow(y2-cy,2)); | |
if(d1 <= r && d2 <= r) continue; | |
else if(d1 <= r) result++; | |
else if(d2 <= r) result++; | |
} | |
printf("%d\n",result); | |
} | |
return 0; | |
} |
예제 입력
2 -5 1 12 1 7 1 1 8 -3 -1 1 2 2 2 5 5 1 -4 5 1 12 1 1 12 1 2 -5 1 5 1 1 0 0 2
예제 출력
3 0
문제의 입출력이 너무 많아서 어려운줄 알았는데,
생각해보면 쉬운 문제다.
원 안에 점이 포함되면 ++
원이 2점을 감싸면 continue
'IT > 알고리즘' 카테고리의 다른 글
Quick Sort (0) | 2017.11.30 |
---|---|
BOJ 백준온라인져지 11651 좌표 정렬하기 2 풀이 (0) | 2017.11.30 |
BOJ 백준온라인져지 1002 터렛 풀이 (0) | 2017.11.30 |
BOJ 백준온라인져지 11866 조세퍼스 문제 0 풀이 (0) | 2017.11.29 |
BOJ 백준온라인져지 10845 큐 풀이 (0) | 2017.11.29 |