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.
๐ ๋ฌธ์ ๋งํฌ
โ๏ธ ์์๋ ์๊ฐ
20m
โจ ์๋ ์ฝ๋
์ ํ์ ์ธ DP ๋ฌธ์ ์ ๋๋ค.
๊ธธ์ด๊ฐ 4์ธ ์ค๋ฅด๋ง ์ ๊ฐ์๋ ๋ง์ง๋ง ์๋ฅผ ์ ์ธํ๋ค๋ฉด ๊ธธ์ด๊ฐ 3์ธ ์ค๋ฅด๋ง ์ ๊ฐ์์ ๊ฐ์ต๋๋ค.
์ต์ ๋ถ๋ถ ๊ตฌ์กฐ๋ฅผ ์ฐพ์ ์ ์์ฃ .
๋ฐ๋ผ์ ๊ธธ์ด๊ฐ i์ผ ๋ ์ค๋ฅด๋ง ์์ ๊ฐ์๋ฅผ ๊ตฌํ ์ ์๊ฒ ์ฃ .
ํ์ง๋ง ์ด๋ฐ ์์ผ๋ก ์ ๋ถ ๊ตฌํ๊ธฐ์ ์๊ฐ ๋๋ฌด ํฝ๋๋ค.
๋ฐ๋ผ์ ์ ์ฝ์ ํ๋ ๋ ์ถ๊ฐํ ์ ํ์์ ์ธ์์ผ ํฉ๋๋ค.
์ฌ๊ธฐ์ ์ ์ ํ ์ ์ฝ์ ๋ง์ง๋ง ์ ์ ๋๋ก ์ธ์๋ณผ ์ ์๊ฒ ๋ค์.
๊ธธ์ด๊ฐ i์ผ ๋ ๋ง์ง๋ง ์๊ฐ j์ธ ์ค๋ฅด๋ง ์์ ๊ฐ์๋ฅผ ๊ตฌํด๋ด ์๋ค.
์ ํ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + ... + dp[i-1][0]๊ฒฐ๊ตญ ๊ฐ๊ฐ์ MOD ์ฐ์ฐํ ๊ฒฐ๊ณผ๋ฅผ ๋ํ๋ฉด ๊ธธ์ด N์ ์ค๋ฅด๋ง ์์ ๊ฐ์๋ฅผ ๊ตฌํ ์ ์์ต๋๋ค.
์๋ ์ฝ๋
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ