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;
}
相关文章
|
4月前
|
数据安全/隐私保护
AD 入门
AD 入门
52 13
|
3月前
|
Java
NSS [NSSRound#7 Team]ec_RCE
NSS [NSSRound#7 Team]ec_RCE
47 0
luogu CF776D The Door Problem(2-sat问题)
luogu CF776D The Door Problem(2-sat问题)
65 0
|
存储 数据安全/隐私保护 异构计算
KUC711AE 3BHB004661R0001 通常用于支持部分重新配置
KUC711AE 3BHB004661R0001 通常用于支持部分重新配置
124 0
  KUC711AE 3BHB004661R0001 通常用于支持部分重新配置
|
监控 流计算
dc_labs--lab1的学习与总结
本节为dc_labs系列的第一篇,主要根据自己对于lab的理解,简述实验的过程,同时对于笔者自己觉得需要进一步理解的进行总结学习。本节重点在于理解启动文件与DC的综合流程。建议与对应博文([DC学习笔记正式篇之零——综述与基本流程介绍](https://guodongblog.com/posts/80912d01b675/))进行结合起来进行学习。该文为对应部分的实践篇的内容。本系列博文不会只是带着进行实验内容,个人觉得单纯跑一遍实验意义不大。会结合自己学习的理解进行部分展开。有问题欢迎留言一起学习。
1066 0
|
存储 机器学习/深度学习 算法
Lec3 基于模型的 CF | 学习笔记
快速学习 Lec3 基于模型的 CF 。
Lec3 基于模型的 CF | 学习笔记
2012 ACM/ICPC Asia Regional Tianjin Online-Faulty Odometer
题意:有个特殊汽车的行程表,每逢数字3和8会跳过直接到4和9,给你一个行程表的示数,求汽车实际走的路程。
133 0
|
数据安全/隐私保护 开发工具 Windows