Codeforces 414-B. Mashmokh and ACM
传送门
- 是一道数位dp,我还是dp太菜了,多做题吧,具体的写在code里面了
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
int n, k;
const int N = 2e3 + 10;
int dp[N][N];
vector<int>g[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (i * j > n) break;
g[i].push_back(i * j);
}
}
for (int i = 1; i <= n; ++i) dp[1][i] = 1;
//dp[i][j] i目前有几个数字,j最后一个数字是多少
for (int i = 1; i <= k; ++i) {
for (int j = 1; j <= n; ++j) {
for (int p = 0; p < g[j].size(); ++p) {
dp[i + 1][g[j][p]] += dp[i][j] % mod;
dp[i + 1][g[j][p]] %= mod;
}
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
ans += dp[k][i] % mod;
ans %= mod;
}
cout << ans % mod << "
";
return 0;
}