[20250825] BOJ / G5 / 좋다 / 이종환 #739
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/1253
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
N개의 수 중에서 어떤 수가 다른 수 두 개의 합으로 나타낼 수 있다면 그 수를 “좋다(GOOD)”고 한다.
N개의 수가 주어지면 그 중에서 좋은 수의 개수는 몇 개인지 출력하라.
수의 위치가 다르면 값이 같아도 다른 수이다.
🔍 풀이 방법
이 문제에서의 핵심은 수의 위치가 다르면 값이 같아도 다른 수인 점이다.
그렇기에 이로 인해서 0 + a = a, 0 + 0 = 0과 같이 일반적이지 않은 케이스로 인해서 생기는 경우를 고려해야한다.
그렇기에 각각의 숫자가 어느 인덱스에 저장되어 있는 지를 HashMap<Integer,HashSet> 방식으로 저장하여서 해결하였다.
⏳ 회고
대충 풀다가 몇번 틀리고 맞췄다. 정확히 설계하자