Skip to content

Commit

Permalink
Merge pull request #32 from AlgoLeadMe/8-suhyun113
Browse files Browse the repository at this point in the history
8-suhyun113
  • Loading branch information
suhyun113 authored Jul 17, 2024
2 parents 385342c + c3f2229 commit fc2f5e9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
| 4μ°¨μ‹œ | 2024.04.06 | DP | [ν”Όλ³΄λ‚˜μΉ˜ 수 5](https://www.acmicpc.net/problem/10870) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/16) |
| 5μ°¨μ‹œ | 2024.04.10 | μŠ€νƒ | [크레인 μΈν˜• 뽑기 κ²Œμž„](https://school.programmers.co.kr/learn/courses/30/lessons/64061) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/19) |
| 6μ°¨μ‹œ | 2024.04.14 | μŠ€νƒ | [컨트둀 제트](https://school.programmers.co.kr/learn/courses/30/lessons/120853) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/21) |
| 7μ°¨μ‹œ | 2024.05.09 | 트리 | [μ›μˆ­μ΄ 맀달기](https://www.acmicpc.net/problem/2716) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/31) |
| 7μ°¨μ‹œ | 2024.05.09 | 트리 | [μ›μˆ­μ΄ 맀달기](https://www.acmicpc.net/problem/2716) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/31) |
| 8μ°¨μ‹œ | 2024.05.14 | μˆ˜ν•™ | [μ–΄λ¦° μ™•μž](https://www.acmicpc.net/problem/1004) | [#32](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/32) |
42 changes: 42 additions & 0 deletions suhyun113/μˆ˜ν•™/8-suhyun113.cpp
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;
}

0 comments on commit fc2f5e9

Please sign in to comment.