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 C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

vector<int> d;
vector<vector<int> > dp(100000, vector<int>(101, -1));

int ans(int n, int k) {
    // cout << n << " " << k << " called" << endl;
    if (n < 0 || n >= (int)d.size())
        return 0;
    else if (k == 1)
        return d[n];
    else if (dp[n][k] != -1)
        return dp[n][k];

    ll a = ans(n - 1, k);
    a = (a + (ll(d[n] - d[n - 1]) * (ll)ans((int)d.size() - n, k - 1)) % MOD) % MOD;

    dp[n][k] = (int)a;
    return (int)a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k, temp = 0;
    cin >> n >> k;
    stack<int> s;
    d.push_back(0);
    for (int i = 1; i * i <= n; i++) {
        if (n / i != temp) {
            d.push_back(i);
            s.push(n / i);
            temp = n / i;
        }
    }
    if (s.top() == d.back()) s.pop();
    while (!s.empty()) {
        int t = s.top();
        d.push_back(t);
        s.pop();
    }

    //debug
    // cout << "divisors ";
    // for (int a : d) cout << a << " ";

    cout << ans((int)d.size() - 1, k);

    return 0;
}