Skip to content

Files

Latest commit

e19a750 ยท Dec 29, 2020

History

History

P1305

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 29, 2020
Dec 29, 2020
Dec 29, 2020

[baekjoon-1305] ๊ด‘๊ณ 

image

ํ’€์ด ๊ณผ์ •

๋ฌธ์ œ๋ฅผ ๋ถ„์„ํ•˜๊ธฐ๋ฅผ, ์•ž์„œ ํ’€์—ˆ๋˜ ๋ฌธ์ž์—ด ๊ฒ€์ƒ‰ ๋ฌธ์ œ์—์„œ๋Š” ์ฐพ์œผ๋ ค๋Š” ๋ฌธ์ž์—ด ํŒจํ„ด์ด ์ฃผ์–ด์ง€๊ณ , ๊ทธ ํŒจํ„ด์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž์—ด์„ ์ฐพ์œผ๋ ค๋Š”๊ฒŒ ๊ณผ์ œ์˜€๋‹ค. ํ•˜์ง€๋งŒ ์ด๋ฒˆ ๋ฌธ์ œ์—์„œ๋Š” ๋ฐ˜๋Œ€๋กœ ํŠน์ • ํŒจํ„ด์ด ๋ฐ˜๋ณต๋˜๋Š” ๋ฌธ์ž์—ด์—์„œ ํŒจํ„ด์„ ์ฐพ๋Š” ๊ฒƒ์ด ๊ณผ์ œ์˜€๋‹ค.

์‹œ๊ฐ„ ํšจ์œจ์„ ์ƒ๊ฐํ•ด๋ณด์•˜์„ ๋•Œ, L์˜ ์ตœ๋Œ€ ํฌ๊ธฐ๊ฐ€ 100๋งŒ์ด๋ฏ€๋กœ ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์„ ๋‹จ ํ•œ ๋ฒˆ๋งŒ for๋ฌธ์œผ๋กœ ํ›‘์–ด์„œ ๋‹ต์„ ๋„์ถœํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋žฌ์„ ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ƒ๊ฐ์ด ์ด์–ด์กŒ๋‹ค.

image

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ํ˜„์žฌ ๊ฒ€์‚ฌํ•˜๋ ค๋Š” ๋ฌธ์ž์—ด ๊ธธ์ด์—์„œ ์ ‘๋‘์‚ฌ์™€ ์ ‘๋ฏธ์‚ฌ๊ฐ€ ๊ฐ™์€ ๊ตฌ๊ฐ„์˜ ๊ธธ์ด๋ฅผ ๋นผ์ฃผ๋ฉด ๋ฐ˜๋ณต๋˜๋Š” ๋ฌธ์ž์—ด ํŒจํ„ด ๋ฐ ๊ทธ ํŒจํ„ด์˜ ๊ธธ์ด๋ฅผ ๋„์ถœํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด ๋•Œ, ํŒจํ„ด์ด 3๋ฒˆ ์ด์ƒ ๋ฐ˜๋ณต๋˜๋Š” ๊ฒฝ์šฐ๋Š”?

image

๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์œ„์™€ ๊ฐ™์ด ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.

KMP ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ makePk ํ•จ์ˆ˜๋Š” ๋ฌธ์ž์—ด์—์„œ ์ ‘๋‘์‚ฌ์™€ ์ ‘๋ฏธ์‚ฌ๊ฐ€ ๊ฐ™์„ ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€์˜ ๊ธธ์ด๋ฅผ ๋ฐฐ์—ด์— ์ €์žฅํ•œ๋‹ค. ์ด ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ๋„์ถœ๋˜๋Š” ๊ฐ’์„ ์ด์šฉํ•˜๋ฉด ์›ํ•˜๋Š” ๋‹ต์„ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค.