Problem:
Score : 600 points

Problem Statement

Find the number of sequences of length K consisting of positive integers such that the product of any two adjacent elements is at most N, modulo 10^9+7.

Constraints

1\leq N\leq 10^9

1 2\leq K\leq 100 (fixed at 21:33 JST)

N and K are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of sequences, modulo 10^9+7.

Sample Input 1

3 2

Sample Output 1

5

(1,1), (1,2), (1,3), (2,1), and (3,1) satisfy the condition.

Sample Input 2

10 3

Sample Output 2

147

Sample Input 3

314159265 35

Sample Output 3

457397712

Solution in Kotlin (1.0.0) (judge verdict: Time Limit Exceeded)

fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    var s = mutableListOf<Pair<Int, Int>>()
    for (i in 1..Math.sqrt(N.toDouble()).toInt()) {
        s.add(Pair(i, 0))
        s.add(Pair(N / i, 0))
    }
    s.sortBy { it.first }
    s = s.distinctBy { it.first }.toMutableList()
    for (i in 0 until s.count() - 1) {
        val l = N / s[i + 1].first
        val r = N / s[i].first
        s[i] = Pair(s[i].first, r - l)
    }
    s[s.count() - 1] = Pair(s[s.count() - 1].first, 1)
    val m = s.count()
    val map = mutableMapOf<Int, Int>()
    repeat(m) {
        map[s[it].first] = it
    }
    var dp = Array<Array<ModInt>>(K + 1) { Array<ModInt>(m, { ModInt(0) }) }
    dp[0][map[N]!!] = ModInt(1)
    for (i in 0 until K) {
        for (j in m - 2 downTo 0) {
            dp[i][j] += dp[i][j + 1]
        }
        repeat(m) {
            val nj = map[N / s[it].first]!!
            dp[i + 1][it] += dp[i][nj] * ModInt(s[it].second.toLong())
        }
    }
    var ans = ModInt(0)
    repeat(m) { ans += dp[K][it] }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

data class ModInt(private var v: Long) {

    companion object {
        private const val MOD = 1000000007L
    }

    init {
        if (v >= MOD) v %= MOD
    }

    operator fun plus(other: ModInt): ModInt {
        val x = v + other.v
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }

    operator fun minus(other: ModInt): ModInt {
        val x = v + MOD - other.v
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(v * other.v % MOD)
    }

    operator fun div(other: ModInt): ModInt {
        return ModInt(v * calc(other.v, MOD - 2) % MOD)
    }

    private fun calc(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2L == 0L) {
            val d = calc(a, b / 2)
            return d * d % MOD
        }
        return a * calc(a, b - 1) % MOD
    }

    override fun toString(): String {
        return v.toString()
    }

}