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/10844
โ๏ธ ์์๋ ์๊ฐ
2์๊ฐ
โจ ์๋ ์ฝ๋
์ด ๋ฌธ์ ๋ ์๋ฆฟ์๊ฐ ์ฃผ์ด์ง๊ณ ๊ทธ์ ์๋ฆฟ์์ ๊ณ๋จ์๋ฅผ ์ ์ฅํด๋์๋ค ๊ณ์ ์ฌํ์ฉํด์ฃผ์ด์ผํ๊ธฐ๋๋ฌธ์
dp
์๊ณ ๋ฆฌ์ฆ์ ์จ์ผํ๋ค ์๊ฐํ์ต๋๋ค.stair_num[i][j]
๋ฐฐ์ด์i
๋์๋ฆฟ์j
๋0~9 ์ธ ์ซ์๋กi๋ฒ์งธ์๋ฆฌ์ ์ซ์j
๊ฐ ์์๋์ ๊ฐ๋ฅํ๊ณ๋จ์
์ ๋๋ค.์ฆ
stair_num[5][6]
์ ๊ฒฝ์ฐ5๋ฒ์งธ์๋ฆฌ์ 6์ด์์๋ ๊ฐ๋ฅํ ๊ณ๋จ์
์ ๊ฐ์ ๊ฐ์ง๋๋ค.์ด ๊ฒฝ์ฐ ๊ฐ๋ฅํ ๊ณ๋จ์๋ (4๋ฒ์งธ์๋ฆฌ์ 5๊ฐ์จ ๊ณ๋จ์+4๋ฒ์งธ์๋ฆฌ 7์ด ์จ ๊ณ๋จ์)์ ๋๋ค.
1)๋ช์๋ฆฟ์์ธ์ง
num
์ ํตํด์ ์ ๋ ฅ๋ฐ์ต๋๋ค.2)์ผ์ ์๋ฆฌ์ผ๊ฒฝ์ฐ
stair_num[1][m]=1(1<=m<=9)
๋ก ์ด๊ธฐํ ํด์ค๋๋ค.(์ผ์์๋ฆฌ์ 0์ด๋ชป์ค๋ฏ๋ก m==0์ ์ธ)3)์ด๋ค์๋ฆฌ์ ์ซ์ 0์ด ์ฌ๊ฒฝ์ฐ 1์ฐจ์ด๊ฐ ๋๋ ๊ฒฝ์ฐ๋ -1,1์ ๊ฒฝ์ฐ๊ฐ์๋๋ฐ -1์ ์์ผ๋ฏ๋ก
stair_num[i-1][1]์ ๊ฒฝ์ฐ๋ง
์๊ฐํ์ฌ์ค๋๋ค.4)๊ทธ์ธ ๊ฒฝ์ฐ๋ ์ ํ์
stair_num[i][j]=(stair_num[i-1][j-1]+stair_num[i-1][j+1])%1000,000,000
(๊ณ์ฐ์ค ์ค๋ฒํ๋ก์ฐ๊ฐ ๋ฐ์ํ ์ ์์ผ๋ฏ๋ก %์ฐ์ฐ์๋ฅผ ์ด์ฉํด์ค๋๋ค.)5)์ต์ข ๊ฒฐ๊ณผ๊ฐ์
stair_num[num][j](0<=j<=9)
์ฆ๋ง์ง๋ง์๋ฆฌ ์ ์ฌ์์๋(0~9) ๊ณ๋จ์์๋ค์ ๋ค ๋ํด์ค๋๋ค.
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
์ฒ์์ ๋ก์ง์ ๋ง๋๋ฐ ํฐ ์๋ฅผ ๋ฃ์ผ๋ฉด ๊ณ์
์ค๋ฒํ๋ก์ฐ
๊ฐ ๋ ์ ์ ๋ฅผ ๋จน์๋๋ฐlong long
์๋ฃํ ๊ณผ ์ฐ์ฐ์ค์%1000,000,000
๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ์ ๋ฎ์ถฐ์ฃผ๋ฉด์ ํด๊ฒฐํ์์ต๋๋ค.์ฐ์ฐ๊ฒฐ๊ณผ๊ฐ์ ์ค๋ฒํ๋ก์ฐ ๋ฟ๋ง์๋๋ผ ๊ณ์ฐ์ค์์๋ ์ค๋ฒํ๋ก์ฐ๋ฅผ ์ ๊ฒฝ์จ์ค์ผํ๋ค๋๊ฒ์ ๊นจ๋ฌ์์ต๋๋ค.