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.42.0) (judge verdict: Accepted)

#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:i64,
        k:usize,
    }
    let mut group = vec![];
    for i in (1..=n).take_while(|&i| i <= n / i) {
        group.push(i);
        if i != n / i {
            group.push(n / i);
        }
    }
    group.sort();
    let group: Vec<(i64, i64)> = group
        .iter()
        .scan(0, |before, &x| {
            let res = (*before + 1, x);
            *before = x;
            Some(res)
        })
        .collect();
    let m = group.len();
    //dp[i][j]:長さi,ラストがgroup[j]に含まれるやつの個数
    let mut dp: Vec<Vec<i64>> = vec![vec![0; m]; k + 1];
    dp[0][0] = 1;
    let modulo = 1e9 as i64 + 7;
    for i in 0..k {
        let mut imos = vec![0; m + 1];
        for j in 0..m {
            let left = 0;
            let right = m - j;
            imos[left] = (imos[left] + dp[i][j]) % modulo;
            imos[right] = (imos[right] - dp[i][j]) % modulo;
        }
        let mut now = 0;
        for j in 0..m {
            now = (now + imos[j]) % modulo;
            let res = now * (group[j].1 - group[j].0 + 1) % modulo;
            dp[i + 1][j] = res;
        }
    }
    let sum = dp
        .last()
        .unwrap()
        .iter()
        .fold(0, |acc, &x| (acc + x) % modulo);
    let ans = if sum >= 0 {
        sum
    } else {
        (sum % modulo + modulo) % modulo
    };
    println!("{}", ans);
}