[20250905] BOJ / G1 / 구간 곱 구하기 / 이준희 #820
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/11505
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
n개의 수가 주어지고
특정 인덱스의 값을 바꾸는 연산 m번
특정 인덱스부터 인덱스 까지의 곱을 구하는 연산 k번 이 주어졌을 때
연산의 결과를 출력하는 문제입니다.
🔍 풀이 방법
세그먼트 트리를 이용해서 풀었습니다.
곱셈이기 때문에 long을 사용했고 출력 조건이 1000000007로 나눈 나머지를 구하는 것이기 때문에 오버플로우 방지를 위해 매 곱셈마다 나머지 연산을 수행했습니다.
⏳ 회고
그냥 세그트리의 3개 메소드를 외웠는데, 생각보다 잘 떠오르지 않아서 구현하는데 시간이 걸렸습니다.
다 구현하고 나서는 그냥 외웠던 대로 만들어 버리니깐 구간 합 구하기에서 처럼, 범위를 벗어나는 경우에 0을 리턴해 버려서 모든 곱이 0으로 나오게 됐는데 이 부분을 파악하는데 불필요하게 시간을 소요한 것 같습니다.