CF414B Mashmokh and ACM

简介: CF414B Mashmokh and ACM

Mashmokh’s boss, Bimokh, didn’t like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh’s team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn’t able to solve them. That’s why he asked you to help him with these tasks. One of these tasks is the following.


A sequence of l integers b1, b2, …, bl (1 ≤ b1 ≤ b2 ≤ … ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally for all i (1 ≤ i ≤ l - 1).


Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109 + 7).


Input

The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).


Output

Output a single integer — the number of good sequences of length k modulo 1000000007 (109 + 7).


如果一个数列中,后一个数都能被前面一个数整除,那么就叫这个数列为好数列。输入n,k,求数列中最大元素为n,数列长度为k的好数列的种数(对1000000007取模)

题解:类似(埃式筛法)

那么首先设计状态,用dp[i][j]来表示长度为i,末位数字为k的情况下,能够达到的最优解。

#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2005;
int dp[maxn][maxn];
int main() {
  int n, m;
  cin >> n >> m;
  dp[0][1] = 1;
  for (int i = 0; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = j; k <= n; k += j) {
        dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % mod;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[m][i]) % mod;
  }
  cout << ans << endl;
  return 0;
}
相关文章
|
1月前
|
数据安全/隐私保护
AD 入门
AD 入门
43 13
|
30天前
|
算法
CF 1561
【7月更文挑战第20天】
29 2
luogu CF776D The Door Problem(2-sat问题)
luogu CF776D The Door Problem(2-sat问题)
54 0
|
人工智能 网络架构
CF 698A
CF 698A
63 0
CF1000F One Occurrence(莫队)
CF1000F One Occurrence(莫队)
44 0
|
JSON 安全 网络协议
Cloud Foundry 3. cf 命令(2)
Cloud Foundry 3. cf 命令(2)
Cloud Foundry 3. cf 命令(2)
|
安全 Java 应用服务中间件
Cloud Foundry 3. cf 命令(1)
Cloud Foundry 3. cf 命令(1)
Cloud Foundry 3. cf 命令(1)