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)

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: usize = 1e+9 as usize + 7;
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let sqn = ((n as f64).sqrt().floor()) as usize;
    let mut kinds = vec![];
    for i in 1..sqn + 1 {
        kinds.push((i, n / i));
    }
    for i in (1..sqn + 1).rev() {
        let mut v = n / (i + 1) + 1;
        kinds.push((v, i));
    }
    kinds.sort();
    kinds.dedup();
    let m = kinds.len();
    let mut width = vec![0; m];
    let mut prev = n + 1;
    for i in (0..m).rev() {
        width[i] = prev - kinds[i].0;
        prev = kinds[i].0;
    }
    // println!("{:?}", kinds);
    let mut dp = vec![0; m];
    dp[0] = 1;
    for _iter in 0..k {
        let mut ndp = vec![0; m];
        let mut sum = 0;
        let mut pos = 0;
        for i in (0..m).rev() {
            while pos < kinds.len() && kinds[pos].0 <= kinds[i].1 {
                sum = (sum + width[pos] * dp[pos]) % MOD;
                pos += 1;
            }
            ndp[i] = sum;
        }
        dp = ndp;
        // println!("{:?}", dp);
    }
    let mut ans = 0;
    for i in 0..m {
        ans = (ans + width[i] * dp[i]) % MOD;
    }
    println!("{}", ans);
}