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: Accepted)

#include<bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;

int arr[63245];

int dp[63245][100];

void init(int n, int &m)
{
    int i = 1;
    int j = 1;
    arr[1] = 1;
    while (i != n)
    {
        i = n / (n / (i + 1));
        ++j;
        
        arr[j] = i;
    }
    m = j;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    
    int m;
    init(n, m);
    
    // cout << m << '\n';
    // for (int i = 1; i <= m; ++i)
    //     cout << arr[i] << '\n';
    
    for (int i = 1; i <= m; ++i)
        dp[i][0] = arr[i];
    
    for (int i = 1; i != k; ++i)
        for (int j = 1; j <= m; ++j)
            dp[j][i] = (dp[j - 1][i] + 1LL * dp[m - j + 1][i - 1] * (arr[j] - arr[j - 1])) % MOD;
    
    // int ans = 0;
    // for (int i = 1; i <= m; ++i)
    //     ans = (ans + dp[i][k - 1]) % MOD;
    // for (int i = 1; i <= m; ++i)
    //     ans = (ans + dp[i][0]) % MOD;
    
    cout << dp[m][k - 1] << '\n';
    
    return 0;
}