Skip to content

Conversation

@ksinji
Copy link
Contributor

@ksinji ksinji commented Oct 28, 2025

🧷 문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/42895

🧭 풀이 시간

40분

👀 체감 난이도

✏️ 문제 설명

숫자 N과 number가 주어질 때, N과 사칙연산만 사용해서 표현 할 수 있는 방법 중 N 사용횟수의 최솟값을 구하라.
ex. N=5, number=12일 때 N 사용 횟수의 최솟값은 4
12 = (55 + 5) / 5 이므로.

🔍 풀이 방법

N을 1개부터 8개까지 사용해 만들 수 있는 모든 수의 조합을 Set에 저장하며 탐색했다.
각 단계에서 이전에 만든 수들을 사칙연산으로 조합해 새로운 수를 만들고,
그중 목표값 number가 나오면 해당 사용 횟수를 반환했다.
8개까지 써도 안나오면 -1 리턴.

⏳ 회고

dp인 건 알겠는데 숫자 n개로 만들 수 있는 수를 저장해두는 생각을 하는 데에 오래 걸렸다

@ksinji ksinji self-assigned this Oct 28, 2025
@ksinji ksinji added the success 👍 해설을 보지 않고 풀었을 때 label Oct 28, 2025
@ksinji ksinji changed the title Create 28 PGM N으로 표현.md [20251028] PGM / LV3 / N으로 표현 / 강신지 Oct 28, 2025
@ShinHeeEul ShinHeeEul merged commit bc5f2e5 into main Oct 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants