백준 - 2164 카드2
문제
2164 카드2
답
kotlin code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
fun main() {
q2164()
}
fun q2164() {
val cards = java.util.LinkedList<Int>()
for(i in 1.. readln().toInt()) {
cards.add(i)
}
while (cards.count() > 2) {
cards.removeFirst()
cards.addLast(cards.removeFirst())
}
println(cards.last)
}
This post is licensed under CC BY 4.0 by the author.