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)

const MOD: i64 = 1e9 as i64 + 7;

fn solve(n: usize, k: usize) -> i64 {
    let sqn = (n as f64).sqrt() as usize;
    let q = n / (sqn + 1);
    let r = sqn + q;

    let mut dp = vec![vec![0i64; 2 * r]; k + 1];

    let mut num = vec![0; r + 1];
    for i in 1..(r + 1) {
        if i <= sqn {
            num[i] = 1;
            dp[1][i] = dp[1][i - 1] + 1;
        } else {
            num[i] = (n / (r - i + 1) - n / (r - i + 2)) as i64;
            dp[1][i] = dp[1][i - 1] + num[i];
        }
    }

    for i in 2..(k + 1) {
        for j in 1..(r + 1) {
            dp[i][j] = (dp[i - 1][r - j + 1] * num[j] + dp[i][j - 1]) % MOD;
        }
    }

    dp[k][r]
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, 2), 5);
    assert_eq!(solve(10, 3), 147);
    assert_eq!(solve(314159265, 35), 457397712);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, k) = parse_line!(usize, usize);
    println!("{}", solve(n, k));
}