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 <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

const LL MOD = 1000000007;

int main(){
    LL n, k;
    cin >> n >> k;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    set<LL> value_set;
    value_set.insert(0);
    for(LL i = 1; ; ++i){
        value_set.insert(i);
        value_set.insert(n/i);
        if(i*i >= n) break;
    }
    vector<LL> values(value_set.begin(), value_set.end());
    LL w = values.size();
    vector<vector<LL>> a(k+1, vector<LL>(w+1));
    for(LL i = 1; i < w; ++i){
        a[0][i] = values[i] - values[i-1];
    }
    for(LL cur = 1; cur <= k; ++cur){
        LL j = 1;
        LL total = 0;
        for(LL i = w-1; i >= 1; --i){
            while(j < values.size() && values[j] * values[i] <= n){
                total = (total + a[cur-1][j]) % MOD;
                ++j;
            }
            a[cur][i] = total * (values[i] - values[i-1]) % MOD;
        }
    }
    cout << a[k][1] << endl;
    return 0;
}