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 Ruby (2.3.3) (judge verdict: Time Limit Exceeded)

N,K = gets.chomp.split.map(&:to_i)

# 最後の数で状態数を持たせると
# 1 100
# 2 50
# ..
# 
# dp[k][i] = sum(dp[k-1][j] | j=1..N/i)
#
# このままだと10**9なので間に合わない
# N/iにまとめて、sqrt(10**9)程度にする
# 
# 0 1 2 3 5 10     N/i=key
#   1 1 1 2 5      k=1
#   10 5 3 4 5     k=2
#   27 22 18 30 50 k=3

# とりえるN/i
keys = [0] #key_rangeを計算するためのダミー
(1..(Math::sqrt(N).floor)).each do |i|
  keys << i
  j = (N/i).floor
  keys << j if i != j
end
keys.sort!

# p keys

#初期状態(k=0)
dp = [nil, 1] #key_rangeを使用するためのダミーに合わせて、最初にnil追加

K.times do
  dp2 = []
  sum = 0
  
  (keys.size-1).downto(0).each_cons(2) do |i, i_before| #後ろから算出
    max_j = keys.size - i # N/iのインデックス
    key_range = keys[i] - keys[i_before]
    # dp2[i] = sum(dp[j] | j=1..max_j)*key_range
    # sum(dp[j] | j=1..max_j)を保存しておくことで、毎回計算しないようにする
    sum += dp[max_j] if dp[max_j]
    dp2[i] = sum * key_range % (10**9+7)
  end

  dp = dp2
  
  # p dp2
end

puts dp[1..-1].inject(&:+) % (10**9+7)