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# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using static Constans;

public static class Constans
{
    public const long Mod = (long)1e9 + 7;
}

public struct ModInt
{
    public long Num;

    public ModInt(long num)
    {
        Num = num;
    }

    // x^n
    public static long Power(long x, long n)
    {
        long pow = 1;
        while (n > 0)
        {
            if (n % 2 == 0)
            {
                x *= x;
                x %= Mod;
                n /= 2;
            }
            else
            {
                pow *= x;
                pow %= Mod;
                n--;
            }
        }

        return pow;
    }

    public static ModInt GetInv(long f)
    {
        // フェルマーの小定理 a^(-1) = a^(mod-2)
        return new ModInt(Power(f, Mod - 2));
    }

    public ModInt GetInv()
    {
        return GetInv(Num);
    }

    public override string ToString()
    {
        return Num.ToString();
    }

    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Num += r.Num;
        if (l.Num >= Mod)
        {
            l.Num -= Mod;
        }
        return l;
    }

    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Num -= r.Num;
        if (l.Num < 0)
        {
            l.Num += Mod;
        }
        return l;
    }

    public static ModInt operator *(ModInt l, ModInt r)
    {
        return new ModInt(l.Num * r.Num % Mod);
    }

    public static implicit operator ModInt(long n)
    {
        n %= Mod;
        if (n < 0)
        {
            n += Mod;
        }
        return new ModInt(n);
    }
}

public class Solution
{
    // O(N^2*K)
    public static void Main0()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];

        var dp = Enumerable.Range(0, K).Select(_ => new int[N + 1]).ToArray();
        for (int j = 1; j <= N; j++)
        {
            dp[0][j] = 1;
        }
        for (int i = 1; i < K; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                for (int x = 1; x <= N / j; x++)
                {
                    dp[i][j] += dp[i - 1][x];
                }
            }
            Console.Error.WriteLine($"i:{i} {string.Join(" ", dp[i])}");
        }

        var sum = dp.Last().Sum();
        Console.WriteLine(sum);
    }

    // 同状態を同一視 O(N*K)
    public static void Main1()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];

        var keys = new List<int>();
        for (int i = 1; i * i <= N; i++)
        {
            keys.Add(i);
            keys.Add(N / i);
        }
        keys = keys.Distinct().OrderBy(v => v).ToList();
        var n = keys.Count;
        var patterns = new int[n];
        for (int i = 0; i < n - 1; i++)
        {
            patterns[i] = N / keys[i] - N / keys[i + 1];
        }
        patterns[n - 1] = 1;

        for (int i = 0; i < n; i++)
        {
            Console.Error.WriteLine($"i:{i} key:{keys[i]} pattern:{patterns[i]}");
        }
        var keyToIndex = keys.Select((k, i) => new { k, i }).ToDictionary(ki => ki.k, ki => ki.i);

        var dp = Enumerable.Range(0, K).Select(_ => new ModInt[n]).ToArray();
        for (int j = 0; j < n; j++)
        {
            dp[0][j] = patterns[j];
        }
        Console.Error.WriteLine($"i:{0} {string.Join(" ", dp[0])}");
        for (int i = 1; i < K; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int x = keyToIndex[N / keys[j]]; x < n; x++)
                {
                    dp[i][j] += dp[i - 1][x] * patterns[j];
                    Console.Error.WriteLine($"i:{i} {string.Join(" ", dp[i])}");
                }
            }
        }

        var sum = dp.Last().Aggregate((a, b) => a + b);
        Console.WriteLine(sum);
    }

    // 累積和 O(√N*K)
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];

        var keys = new List<int>();
        for (int i = 1; i * i <= N; i++)
        {
            keys.Add(i);
            keys.Add(N / i);
        }
        keys = keys.Distinct().OrderBy(v => v).ToList();
        var n = keys.Count;
        var patterns = new int[n];
        for (int i = 0; i < n - 1; i++)
        {
            patterns[i] = N / keys[i] - N / keys[i + 1];
        }
        patterns[n - 1] = 1;

        var keyToIndex = keys.Select((k, i) => new { k, i }).ToDictionary(ki => ki.k, ki => ki.i);

        var dp = Enumerable.Range(0, K).Select(_ => new ModInt[n]).ToArray();
        dp[0] = patterns.Select(v => new ModInt(v)).ToArray();
        for (int i = 1; i < K; i++)
        {
            for (int j = n - 2; j >= 0; j--)
            {
                dp[i - 1][j] += dp[i - 1][j + 1];
            }

            for (int j = 0; j < n; j++)
            {
                dp[i][j] += dp[i - 1][keyToIndex[N / keys[j]]] * patterns[j];
            }
        }

        var sum = dp.Last().Aggregate((a, b) => a + b);
        Console.WriteLine(sum);
    }
}