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 <stdio.h>
int main(){
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    long long int m;
    m=1000000000+7;
    long long int dp[101][100001];
    long long int a[100001];
    long long int b[100001];
    long long int i;
    long long int j;
    long long int k;
    k=0;
    long long int l;
    long long int s;
    long long int c,d;
    long long int ans;
    ans=0;
    for(c=1;c<=N;c=d+1){
        d=N/(N/c);
        k=k+1;
        a[k]=c;
        b[k]=d;
    }
    dp[0][1]=1;
    for(i=1;i<=K;i++){
        l=0;
        s=0;
        for(j=k;j>=1;j--){
            if(l+1<=k&&a[l+1]*a[j]<=N){
                l=l+1;
                s=(s+dp[i-1][l])%m;
            }
            dp[i][j]=((b[j]-a[j]+1)*s)%m;
            if(i==K){
                ans=(ans+dp[K][j])%m;
            }
        }
    }
    printf("%lld",ans);
}