diff --git a/suhyun113/README.md b/suhyun113/README.md index d79604f..ac4efaf 100644 --- a/suhyun113/README.md +++ b/suhyun113/README.md @@ -6,4 +6,7 @@ | 2차시 | 2024.03.29 | 수학 | [소수 & 팰린드롬](https://www.acmicpc.net/problem/1747) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/9) | | 3차시 | 2024.04.02 | 그리디 | [거스름돈](https://www.acmicpc.net/problem/14916) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/12) | | 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) | \ No newline at end of file +| 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) | +| 8차시 | 2024.05.14 | 수학 | [어린 왕자](https://www.acmicpc.net/problem/1004) | [#32](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/32) | \ No newline at end of file diff --git "a/suhyun113/\354\210\230\355\225\231/8-suhyun113.cpp" "b/suhyun113/\354\210\230\355\225\231/8-suhyun113.cpp" new file mode 100644 index 0000000..d536df4 --- /dev/null +++ "b/suhyun113/\354\210\230\355\225\231/8-suhyun113.cpp" @@ -0,0 +1,42 @@ +// 1004 : 어린 왕자 + +#include +#include +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; +} \ No newline at end of file diff --git "a/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" "b/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" new file mode 100644 index 0000000..6018767 --- /dev/null +++ "b/suhyun113/\354\212\244\355\203\235/6-suhyun113.py" @@ -0,0 +1,20 @@ +def solution(s): + answer = 0 + + stack = [float("inf")] + + # 문자열을 공백 기준으로 나누어 리스트에 저장 + s_list = s.split() + + for i in s_list: # i는 s_list의 인덱스가 아닌 값 + if i != 'Z': + stack.append(i) + else: + stack.pop() # stack의 가장 위의 값 빼기 + stack.pop(0) + + # 문자를 정수로 변환하기 + for i in stack: + n = int(i) + answer += n + return answer \ No newline at end of file diff --git "a/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" "b/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" new file mode 100644 index 0000000..f12a44f --- /dev/null +++ "b/suhyun113/\355\212\270\353\246\254/7-suhyun113.py" @@ -0,0 +1,27 @@ +# 2716 : 원숭이 매달기 + +N = int(input()) # 테스트 케이스의 개수 +results = [] + +for _ in range(N): + s = input().strip() + len_s = len(s) + + depth = 0 + max_depth = 0 + + for i in range(len_s): + if (s[i] == '['): + depth += 1 + if (depth > max_depth): + max_depth = depth + elif (s[i] == ']'): + depth -= 1 + + result = 1 #나무 꼭대기 도달위해 최소 한 마리 원숭이 필요 + for _ in range(max_depth): + result *= 2 + results.append(result) + +for result in results: + print(result) \ No newline at end of file