์ƒˆ์†Œ์‹

๐Ÿงฎ PS

๋ฐฑ์ค€(boj) ํŒŒ์ด์ฌ - 11866 ๋ฒˆ : ์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ 0

  • -

๋ฌธ์ œ๋งํฌ : https://www.acmicpc.net/problem/11866

 

11866๋ฒˆ: ์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ 0

์ฒซ์งธ ์ค„์— N๊ณผ K๊ฐ€ ๋นˆ ์นธ์„ ์‚ฌ์ด์— ๋‘๊ณ  ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ K ≤ N ≤ 1,000)

www.acmicpc.net

 

 

 

 

 

 

 

์˜ˆ์ „์— ํ’€์—ˆ๋˜ ์š”์„ธํ‘ธ์Šค์™€ ๊ฐ™์€๋‚ด์šฉ์ด์—ˆ๋‹ค. ๋‹ค๋ฅธ์ ์€ ์‹œ๊ฐ„์ œํ•œ๋ฟ..?

๋ถ„๋ช… ํ’€์—ˆ๋˜ ๋ฌธ์ œ์ธ๋ฐ ์ฒ˜์Œ ํ’€๋“ฏ์ด ๋‹ค์‹œํ’€๊ฒŒ๋˜์—ˆ๋‹ค........... ๊ธฐ์–ต๋ ฅ ์ฐธ

 

https://infinitt.tistory.com/213

 

๋ฐฑ์ค€ (boj) ํŒŒ์ด์ฌ - 1158 ์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ

๋ฌธ์ œ ๋งํฌ : https://www.acmicpc.net/problem/1158 1158๋ฒˆ: ์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ ์ฒซ์งธ ์ค„์— N๊ณผ K๊ฐ€ ๋นˆ ์นธ์„ ์‚ฌ์ด์— ๋‘๊ณ  ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ K ≤ N ≤ 5,000) www.acmicpc.net N๋ช…์˜ ์‚ฌ๋žŒ๋“ค์ด ์žˆ๊ณ , K๋ฅผ..

infinitt.tistory.com

์ •๋‹ต์ฝ”๋“œ (Python)

N, K = map(int,input().split())
arr = [i for i in range(1,N+1)]
answer = []
idx = -1
for _ in range(N):
    idx += K
    if idx >= len(arr) :
        idx %= len(arr)
    answer.append(str(arr.pop(idx)))
    idx -=1


print("<",", ".join(answer),">",sep='')

 

Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.