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 ll[100010], rr[100010];
long long dp[100010], ndp[100010], sum[100010];
int tot;

int main(){
	int n, k; scanf("%d%d", &n, &k);
	int pos = 1;
	while (pos != n + 1){
		int l = pos, r = n + 1;
		while (l < r){
			int mid = l + r + 1 >> 1;
			if (n / mid != n / pos) r = mid - 1;
			else l = mid;
		}
		ll[++tot] = pos, rr[tot] = l;
		pos = l + 1;
	}
	for (int i = 1; i <= tot; i++){
		dp[i] = 1;
	}
	for (int i = 1; i < k; i++){
		for (int j = 1; j <= tot; j++){
			sum[j] = (sum[j - 1] + dp[j] * (rr[j] - ll[j] + 1)) % mod;
		}
		for (int j = tot; j >= 1; j--){
			int pos = lower_bound(rr + 1, rr + tot + 1, n / ll[j]) - rr;
			ndp[j] = (sum[pos - 1] + dp[pos] * (n / ll[j] - ll[pos] + 1)) % mod;
		}
		swap(ndp, dp);
	}
	long long ans = 0;
	for (int i = 1; i <= tot; i++){
		ans = (ans + dp[i] * (rr[i] - ll[i] + 1)) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}