[백준/코틀린] 11866번: 요세푸스 문제 0
실버 4
링크
풀이
생략
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
fun main() {
val (n, k) = readln().split(" ").map { it.toInt() }
val deque = ArrayDeque((1..n).toList())
val ans = mutableListOf<Int>()
while (deque.isNotEmpty()) {
repeat(k - 1) { deque.addLast(deque.removeFirst()) }
ans.add(deque.removeFirst())
}
println(ans.joinToString(", ", "<", ">"))
}
This post is licensed under CC BY 4.0 by the author.