https://codeforces.com/contest/1359/problem/E
2.Idea
a1 must be a divisor of a2..aN.
3.Source
Int fact[N], invfact[N], inv[N];
void init()
{
fact[0] = 1;
for (int i = 1; i < N; i++) {
fact[i] = fact[i - 1] * i % MOD;
}
inv[1] = 1;
for (int i = 2; i < N; i++) {
inv[i] = -inv[MOD%i] * (MOD / i) % MOD;
if (inv[i] < 0) inv[i] += MOD;
}
invfact[0] = 1;
for (int i = 1; i < N; i++) {
invfact[i] = invfact[i - 1] * inv[i] % MOD;
}
}
Int nCk(Int n, Int k)
{
return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
Int nPk(Int n, Int k)
{
return fact[n] * invfact[n - k] % MOD;
}
Int n, k;
int main()
{
cin >> n >> k;
init();
Int ans = 0;
for (int i = 1; i <= n; i++) {
int num = (n / i);
if (num >= k) {
ans = (ans + nCk(num - 1, k - 1)) % MOD;
}
}
cout << ans << endl;
return 0;
}
No comments:
Post a Comment