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 (GCC 5.4.1) (judge verdict: Accepted)

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

int cmp_int (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 len = 1;
  i32 *f = ALLOC (100000, i32);
  i32 i = 1;
  for (; i * i < n; ++i) {
    f[len++] = i;
    f[len++] = n / i;
  }
  if (i * i == n) {
    f[len++] = i;
  }
  SORT (f, len, cmp_int);
  for (i32 i = len - 1; i >= 1; --i) {
    f[i] -= f[i - 1];
  }
  const i32 mod = 1000000007;
  i32 *dp = ALLOC (len, i32);
  i32 *imos = ALLOC (len + 1, i32);
  dp[1] = 1;
  for (i32 i = 1; i <= k; ++i) {
    for (i32 j = 1; j < len; ++j) {
      imos[len - j] = dp[j];
    }
    for (i32 j = len - 1; j >= 1; --j) {
      imos[j] = (imos[j] + imos[j + 1]) % mod;
      dp[j] = (i64) imos[j] * f[j] % mod;
    }
  }
  i64 ans = 0;
  for (i32 i = 1; i < len; ++i) {
    ans += dp[i];
  }
  ans %= mod;
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}