B. Mashmokh and ACM

纯粹的發表於2024-06-08

原題連結

題解

關鍵因素:調和級數 \(\frac{1}{n}+\frac{1}{n-1}+...+\frac{1}{2}+\frac{1}{1}\) 可以近似看成 \(log(n)\)

code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll dp[2005][2005];

inline void read(ll &x) {
	x = 0;
	ll flag = 1;
	char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-')flag = -1;
        c = getchar();
    }
	while(c >= '0' && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	x *= flag;
}

inline void write(ll x)
{
    if(x < 0){
    	putchar('-');
		x = -x;
	}
    if(x > 9)
		write(x / 10);
    putchar(x % 10 + '0');
}

int main()
{
    ll n, m;
    read(n);
    read(m);

    for(ll i=1; i<=n; i++) dp[1][i]=1;
    for(ll i=1; i<m; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            for(ll k=j; k<=n; k+=j)
            {
                dp[i+1][k]+=dp[i][j];
                dp[i+1][k]%=mod;
            }
        }
    }

    ll ans=0;
    for(ll i=1; i<=n; i++)
    {
        ans+=dp[m][i];
        ans%=mod;
    }
    write(ans);
    return 0;
}