-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1004.cpp
More file actions
39 lines (36 loc) · 832 Bytes
/
1004.cpp
File metadata and controls
39 lines (36 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 1004. 어린왕자
// 2019.05.14
#include<iostream>
using namespace std;
int main()
{
int t;
cin >> t;
while (t > 0)
{
t--;
//출발점과 도착점 입력
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int count = 0;
for (int j = 0; j < n; j++)
{
int x, y, r, distance;
cin >> x >> y >> r;
// 두 점(출발점과 도착점)중 하나만 원 안에 있다면 count를 증가시켜 준다.
// distance가 반지름의 제곱보다 크다면 원 밖. 작다면 원안에 있다.
distance = (x - x1) * (x - x1) + (y - y1) * (y - y1);
bool in1 = distance > r * r ? false : true;
distance = (x - x2) * (x - x2) + (y - y2) * (y - y2);
bool in2 = distance > r * r ? false : true;
if (in1 != in2)
{
count++;
}
}
cout << count << endl;
}
return 0;
}