restructure zeta/** to storage/zeta/**

This commit is contained in:
2025-05-10 21:54:24 +09:00
parent 2886820691
commit 2f2e0759fd
407 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
fun bfs(N: Int): Int {
val D = ArrayDeque<Pair<Int, Int>>()
D.addLast(Pair(N, 0))
while (D.isNotEmpty()) {
val (now, step) = D.removeFirst()
if (now == 1) {
return step
}
if (now % 3 == 0) {
D.addLast(Pair(now / 3, step + 1))
}
if (now % 2 == 0) {
D.addLast(Pair(now / 2, step + 1))
}
D.addLast(Pair(now - 1, step + 1))
}
return -1
}
fun main() {
val N = readln().toInt()
println(bfs(N));
}