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.
π λ¬Έμ λ§ν¬
1,2,3 λνκΈ° 3
βοΈ μμλ μκ°
1μκ°
β¨ μλ μ½λ
λ¨Όμ μ νμμ μΈμ λ€. λνΌλ μμ μ μ΄μ μ΄λ€ κ²½μ°μ μκ° λμ€λμ§ νμΈν΄μΌ μ΄λ»κ² νΈλμ§ λμ 보μ΄λ κ² κ°λ€.
λ¨Όμ n=1 λΆν° λͺ κ°μ§ κ²½μ°μ μκ° λμ€λμ§ μ²΄ν¬νλ€. λ¬Έμ μ μμμ μμκΉμ§ κ³ λ €νλ€.
n=1 μΌ λ
(1)
n=2 μΌ λ
(1,1), (2)
n=3 μΌ λ
(1,1,1), (1,2), (2,1), (3)
n=4 μΌ λ
(1,1,1,1), (1,1,2), (1,2,1), (2,1,1), (2,2), (1,3), (3,1)
μ 리
μ¬κΈ°μ
dp[n] = dp[n-3]+dp[n-2]+dp[n-1]
μ μ νμμ μ»μ μ μλ€.μ½λ
dpμ n=1 λΆν° 4κΉμ§μ κ²½μ°μ μλ₯Ό μ μ₯νμ¬ pλ₯Ό 4λΆν° κ³μ°νλλ‘ νλ€. nμ΄ pλ³΄λ€ μμμ§κΈ° μ κΉμ§ κ³μ°νμ¬ nμ ν΄λΉνλ μΈλ±μ€μΈ
n-1λ²μ§Έ
dpλ₯Ό μΆλ ₯νλ€.π μλ‘κ² μκ²λ λ΄μ©
dpλ μ νμλΆν° ꡬνμ.