[20260121] BOJ / G3 / 소수의 연속합 / 이준희 #1808
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/1644
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
3 : 3 (한 가지)
41 : 2+3+5+7+11+13 = 11+13+17 = 41 (세 가지)
53 : 5+7+11+13+17 = 53 (두 가지)
위 예시 처럼 어떤 자연수가 연속된 소수들의 덧셈으로 생성할 수 있을 때 그 가짓수를 구하는 문제입니다.
🔍 풀이 방법
소수를 계산해서 유지한 후
해당 소수를 유지한 배열에서 투포인터를 사용해서 합을 내가 찾고자 하는 자연수와 비교했습니다.
자연수와 같아질 때 마다 횟수를 세어 답을 냈습니다.
⏳ 회고
항상 소수판별 문제는 소수를 어떻게 판별할지 몰랐어서 미뤄놨었는데
에라토스테네스의 체에 대해서 학습 후 풀었습니다.