2847 python
-
[Python] 2847 ๊ฒ์์ ๋ง๋ ๋์ค์ดAlgorithm/๋ฐฑ์ค 2023. 1. 31. 14:15
1. ๋ฌธ์ ๐ https://www.acmicpc.net/problem/2847 2847๋ฒ: ๊ฒ์์ ๋ง๋ ๋์ค์ด ํ๊ต์์ ๊ทธ๋ํฝ์ค ์์ ์ ๋ค์ ๋์ค์ด๋ ์์ ์๊ฐ์ ๋ค์ ๋ด์ฉ์ ๋ฐํ์ผ๋ก ์ค๋งํธํฐ ๊ฒ์์ ๋ง๋ค์๋ค. ๊ฒ์์๋ ์ด N๊ฐ์ ๋ ๋ฒจ์ด ์๊ณ , ๊ฐ ๋ ๋ฒจ์ ํด๋ฆฌ์ดํ ๋ ๋ง๋ค ์ ์๊ฐ ์ฃผ์ด์ง๋ค. ํ๋ ์ด์ด www.acmicpc.net 2. ์ ์ถ๋ ฅ ์ ๐ 3. ์๊ณ ๋ฆฌ์ฆ โ ์ ์๋ฅผ ๋ด๋ฆฌ๋ ๊ฒ์ ์ต์ํ์ผ๋ก ํ๋ ๋ฐฉ๋ฒ์ ๋ค์ ์ซ์๊ฐ 1์ด ๋ ํฌ๋ฉด ๋๋ค → ๊ทธ๋ฆฌ๋ ๋๋ while ๋ฌธ์ ๋๋ ค๊ฐ๋ฉฐ ํ๋์ฉ -1์ ํด์ฃผ๊ณ ๋ง์ง๋ง์ ๋ฆฌ์คํธ๋ฅผ ์ ๋ถ ์ํํ๋ฉฐ ๋ค์ ์ซ์๊ฐ ํฐ ์ง ๋ค์ ์ฒดํฌ๋ฅผ ํด์ฃผ์๋ค. ๋ง๊ธดํ์ง๋ง, ๋ ์ข์ ๋ฐฉ๋ฒ์ด ์์ ๊ฒ๊ฐ์ ๊ตฌ๊ธ๋งํด๋ณด์๋ค! ๋ค๋ฅธ ์ฌ๋๋ค ์ฝ๋๋ฅผ ๋ณด๋ ๋ค์๋ถํฐ ๋ฆฌ์คํธ๋ฅผ ์ํํ๋ฉฐ ๋ค์ ๊ฐ๋ณด๋ค 1๋งํผ ..