-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from AlgoLeadMe/8-suhyun113
8-suhyun113
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 1004 : μ΄λ¦° μμ | ||
|
||
#include <iostream> | ||
#include <cmath> | ||
using namespace std; | ||
|
||
int main() { | ||
int T; // ν μ€νΈ μΌμ΄μ€μ κ°μ | ||
int x1, y1, x2, y2; // μΆλ°μ , λμ°©μ | ||
int n; // νμ±μ κ°μ | ||
int cx, cy, r; // νμ±κ³μ μ€μ κ³Ό λ°μ§λ¦ | ||
|
||
cin >> T; | ||
while(T--) { | ||
cin >> x1 >> y1 >> x2 >> y2; | ||
cin >> n; | ||
|
||
int enter = 0; // μ§μ νμ | ||
int departure = 0; // μ΄ν νμ | ||
int count = 0; // μ΅μ’ μ§μ /μ΄ν νμ | ||
|
||
while(n--) { | ||
cin >> cx >> cy >> r; | ||
float startDistance = sqrt(pow(cx - x1, 2) + pow(cy - y1, 2)); // μΆλ°μ κ³Ό μ μ¬μ΄μ 거리 | ||
float endDistance = sqrt(pow(cx - x2, 2) + pow(cy - y2, 2)); // λμ°©μ κ³Ό μ μ¬μ΄μ 거리 | ||
|
||
if (startDistance < r){ // μΆλ°μ μ΄ μ λ΄λΆμ μκ³ , | ||
if (endDistance > r) { // λμ°©μ μ΄ μ μΈλΆμ μμ | ||
departure++; // μΆλ°μ ν¬ν¨νλ νμ± -> μ΄ν νμ μ¦κ° | ||
} | ||
} | ||
if (startDistance > r) { // μΆλ°μ μ΄ μ μΈλΆμ μκ³ , | ||
if (endDistance < r) { // λμ°©μ μ΄ μ λ΄λΆμ μμ | ||
enter++; // λμ°©μ ν¬ν¨νλ νμ± -> μ§μ νμ μ¦κ° | ||
} | ||
} | ||
} | ||
count = enter + departure; // μ΅μ’ μ§μ /μ΄ν νμ | ||
cout << count << endl; | ||
} | ||
return 0; | ||
} |