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 Rust (1.15.1) (judge verdict: Accepted)

#![allow(non_snake_case)]

use std::io::Read;

const MOD: i64 = 1_000_000_007;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut s: usize = (n as f64).sqrt().floor() as usize;
    while (s + 1) * (s + 1) < n {
        s += 1;
    }

    let mut dp_a = vec![vec![0; s + 1 as usize]; k + 1];
    let mut dp_b = vec![vec![0; s + 1 as usize]; k + 1];
    //    dbg!(s);
    dp_a[0][1] = 1;

    for i in 0..k {
        let mut sum = 0;
        for j in 1..s + 1 {
            sum += dp_a[i][j];
            sum %= MOD;
        }
        dp_a[i + 1][s] = sum + dp_b[i][s];
        for j in 1..s {
            let idx = s - j;
            dp_a[i + 1][idx] = dp_a[i + 1][idx + 1] + dp_b[i][idx];
            dp_a[i + 1][idx] %= MOD;
        }
        let mut tmp_sum = 0;
        for j in 1..s + 1 {
            tmp_sum += dp_a[i][j];
            dp_b[i + 1][j] = tmp_sum * ((n / j) - std::cmp::max(n / (j + 1), s)) as i64;
            dp_b[i + 1][j] %= MOD;
        }
        //        dbg!(&dp_a);
        //        dbg!(&dp_b);
    }

    let mut res = 0;
    for i in 1..s + 1 {
        res += dp_a[k][i] + dp_b[k][i];
        res %= MOD;
    }
    println!("{}", res)
}