mirror of
https://gitlab.com/mfocko/Codeforces.git
synced 2024-12-22 09:01:26 +01:00
23 lines
417 B
Kotlin
23 lines
417 B
Kotlin
//import readInt
|
|
|
|
fun removeTrailingZeros(n: Int): Int =
|
|
if (n % 10 == 0)
|
|
removeTrailingZeros(n / 10)
|
|
else
|
|
n
|
|
|
|
fun f(n: Int): Int = removeTrailingZeros(n + 1)
|
|
|
|
fun findReachable(n: Int): Int {
|
|
val reachable = mutableSetOf<Int>()
|
|
var m = n
|
|
|
|
while (reachable.add(m)) m = f(m)
|
|
|
|
return reachable.size
|
|
}
|
|
|
|
fun main() {
|
|
val n = readLine()!!.toInt()
|
|
println(findReachable(n))
|
|
}
|