http://codeforces.com/problemset/problem/414/B

B. Mashmokh and ACM
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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).

Sample test(s)
input
3 2
output
5
input
6 4
output
39
input
2 1
output
2
Note

In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

题意:1~n组成的不下降序列,求出序列长度为k的序列种数,每个序列满足序列中的后一个数都能整除前一个数。

思路:后一个数的确定只与前一个数有关,设dp[i][j]表示长度为i的序列中的最后一个数为j,则dp[i][z] = dp[i][z]+dp[i-1][j],其中z是j的倍数。

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int MOD=;
int dp[][];
int main()
{
int n,k;
while(cin>>n>>k)
{
memset(dp,,sizeof(dp));
for (int i = ; i <= n; i++)
dp[][i] = ;
for (int i = ; i <= k; i++)
{
for (int j = ; j <= n; j++)
{
for (int z = j; z <= n; z+=j)
{
dp[i][z] = (dp[i][z]+dp[i-][j])%MOD;
}
}
}
int ans = ;
for (int i = ; i <= n; i++)
{
ans+=dp[k][i];
ans%=MOD;
}
cout<<ans<<endl;
}
return ;
}

B. Mashmokh and ACM(dp)的更多相关文章

  1. codeforces 414B B. Mashmokh and ACM(dp)

    题目链接: B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP

                                                 B. Mashmokh and ACM                                     ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. codeforces D.Mashmokh and ACM

    题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...

  5. CodeForces 415D Mashmokh and ACM

    $dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{}  {dp[i - 1][k]}$ ...

  6. CF414B Mashmokh and ACM

    思路: dp. 实现: 1.O(n5/2) #include <iostream> #include <cstdio> using namespace std; ; ][]; ...

  7. CF 414B Mashmokh and ACM 动态规划

    题意: 给你两个数n和k.求满足以下条件的数列有多少个. 这个数列的长度是k: b[1], b[2], ……, b[k]. 并且 b[1] <= b[2] <= …… <= b[k] ...

  8. Codeforces 414B Mashmokh and ACM

    http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...

  9. Mashmokh and ACM CodeForces - 414D (贪心)

    大意: 给定n结点树, 有k桶水, p块钱, 初始可以任选不超过k个点(不能选根结点), 在每个点放一桶水, 然后开始游戏. 游戏每一轮开始时, 可以任选若干个节点关闭, 花费为关闭结点储存水的数量和 ...

随机推荐

  1. myeclipse工具常用的用法

    1.  自动提示:窗口->首选项->Java->编辑器->内容辅助->自动激活,在下面的“Java的自动激活触发器里面填上“.abcdefghijklmnopqrstuv ...

  2. 透彻分析C/C++中memset函数

    在C语言中,经常需要对内存进行操作,里面涉及很多函数,但是memset函数的使用有一点需要大家格外注意,这也是我在做项目时遇到过的一个问题,调试了很久才找出来错误. 函数原型是:void *memse ...

  3. 瑞芯微ROCK960 RK3399烧录image后扩容rootfs

    问题描述: RK3399开发板烧录官网提供的ubuntu镜像: Ubuntu 16.04 Server arm64(下载地址:https://www.96boards.org/documentatio ...

  4. react入门-----(jsx语法,在react中获取真实的dom节点)

    1.jsx语法 var names = ['Alice', 'Emily', 'Kate']; <!-- HTML 语言直接写在 JavaScript 语言之中,不加任何引号,这就是 JSX 的 ...

  5. 08.C语言:特殊函数

    C语言:特殊函数 1.递归函数: 与普通函数比较,执行过程不同,该函数内部调用它自己,它的执行必须要经过两个阶段:递推阶段,回归阶段: 当不满足回归条件,不再递推: #include <stdi ...

  6. Linux学习总结(21)——CentOS7环境下FTP服务器的安装和配置

    1. 安装vsftpd #安装vsftpd yum install -y vsftpd #设置开机启动 systemctl enable vsftpd.service # 重启 service vsf ...

  7. [K/3Cloud]实现双击列表行后显示具体的某个单据明细。

    列表插件重写void ListRowDoubleClick(ListRowDoubleClickArgs e)事件,在事件中处理具体逻辑,具体代码如下 public override void Lis ...

  8. 听SEO大神夜息分享

    今天偶然听说了百度站长平台,又偶然在上面发现了夜息大神的分享(http://zhanzhang.baidu.com/college/videoinfo?id=871). 之前对于SEO的了解只限于减少 ...

  9. Ubuntu 16.04清楚Dash历史记录

    1.[系统设置]->[安全和隐私]->[文件和应用]->[清除使用数据] 2.清楚播放记录 rm -v ~/.local/share/recently-used.xbel 3.清楚打 ...

  10. Ubuntu 16.04添加阿里云源/163源

    添加国内源有个好处,比如下载软件时直接时国内的服务器,速度有保证. 以下是操作方法: 1.备份 sudo cp /etc/apt/sources.list /etc/apt/sources.list. ...