题目网址: http://codeforces.com/problemset/problem/414/B

Description

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 Input

Input
3 2
Output
5
Input
6 4
Output
39
Input
2 1
Output
2

Hint

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

#include <stdio.h>
#include <string.h>
#include <iostream> using namespace std ;
const int N=;
const int mod=1e9+;
int dp[N][N]; //dp[i][j]表示长度为i,最后一个元素为j的序列数。 int main()
{
int n,k;
while(cin>>n>>k)
{
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
dp[][i]=;
for(int t=;t<k;t++)
{
for(int i=;i<=n;i++)
{
for(int j=;i*j<=n;j++)
{
dp[t+][i*j]+=dp[t][i];//从i=1循环到n,i*j即凡是i的倍数的dp值均加上上一行(序列长度少一)的dp[t][i]值。
dp[t+][i*j]%=mod;
}
}
}
int set=;
for(int i=;i<=n;i++)
{
set+=dp[k][i];
set%=mod;
}
cout<<set<<endl;
}
return ;
}

序列中找子序列的dp的更多相关文章

  1. 17082 两个有序数序列中找第k小

    17082 两个有序数序列中找第k小 时间限制:1000MS  内存限制:65535K 提交次数:0 通过次数:0 题型: 编程题   语言: 无限制 Description 已知两个已经排好序(非减 ...

  2. 17082 两个有序数序列中找第k小(优先做)

    17082 两个有序数序列中找第k小(优先做) 时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC;VC Description 已 ...

  3. 17082 两个有序数序列中找第k小(优先做) O(logn)

    17082 两个有序数序列中找第k小(优先做) 时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC;VC Description 已 ...

  4. [leetcode33Search in Rotated Sorted Array]在排序旋转后序列中找目标值

    直接上代码 /** * Created by lvhao on 2017/6/30. * Suppose an array sorted in ascending order is rotated a ...

  5. 在线性级别时间内找出无序序列中的第k个元素

    在一个无序序列中找出第k个元素,对于k很小或者很大时可以采取特殊的方法,比如用堆排序来实现 .但是对于与序列长度N成正比的k来说,就不是一件容易的事了,可能最容易想到的就是先将无序序列排序再遍历即可找 ...

  6. 【python cookbook】【数据结构与算法】12.找出序列中出现次数最多的元素

    问题:找出一个元素序列中出现次数最多的元素是什么 解决方案:collections模块中的Counter类正是为此类问题所设计的.它的一个非常方便的most_common()方法直接告诉你答案. # ...

  7. [PY3]——找出一个序列中出现次数最多的元素/collections.Counter 类的用法

    问题 怎样找出一个序列中出现次数最多的元素呢? 解决方案 collections.Counter 类就是专门为这类问题而设计的, 它甚至有一个有用的 most_common() 方法直接给了你答案 c ...

  8. 【python cookbook】找出序列中出现次数最多的元素

    问题 <Python Cookbook>中有这么一个问题,给定一个序列,找出该序列出现次数最多的元素.例如: words = [ 'look', 'into', 'my', 'eyes', ...

  9. 剑指 Offer 44. 数字序列中某一位的数字 + 找规律 + 数位

    剑指 Offer 44. 数字序列中某一位的数字 Offer_44 题目描述 题解分析 java代码 package com.walegarrett.offer; /** * @Author Wale ...

随机推荐

  1. CLR VIA

     标题  状态  内容 什么是CLR? 什么是托管模块? 托管模块由什么组成? .net代码的执行过程   http://www.cnblogs.com/aaa6818162/p/4726581.ht ...

  2. 15款效果很酷的最新jQuery/CSS3特效

    很久没来博客园发表文章了,今天就分享15款效果很酷的最新jQuery/CSS3特效,废话不说,一起来看看吧. 1.3D图片上下翻牌切换 一款基于jQuery+CSS3实现的3D图片上下翻牌切换效果,支 ...

  3. 一步步教你搭建VS环境下用C#写WebDriver脚本

    一步步教你搭建VS环境下用C#写WebDriver脚本http://www.automationqa.com/forum.php?mod=viewthread&tid=3529&fro ...

  4. Selenium自动化测试实践 公开班(广州)

    Selenium自动化测试实践 公开班(广州) http://gdtesting.com/product.php?id=115

  5. Visual Studio快捷键 [VS2008/VS2005]快捷键

    VS系统通用快捷键: 1.自动排版(类似VC6中的Alt+F8) 编辑.格式化选定内容 Ctrl + K,Ctrl + F 根据周围的代码行,正确缩进选定的代码行. 2.注释与去掉注释功能. 编辑.注 ...

  6. 译:在C#中使用LINQ To SQL

    译文出处:http://www.codeproject.com/Tips/871938/LINQ-To-SQL-Using-Csharp 今天在这个话题中,我给大家分享一个在c#编程中非常有趣和十分有 ...

  7. myeclipse不编译解决方法

    在开发中经常遇到myeclipse不编译的情况,但不同情况的解决方法又不一样,今天同样是遇到此类情况,在网上狂搜,终于找到一篇好文,它囊括了解决这种情况的常用的方法,现在发出来与大家分享.我遇到的情况 ...

  8. swift也开源了.

    swift也开源了 微软好多也开源. 这世界都开源了 你还等啥. 是因为 B2D 模式吗. 开发者人数众多, 足可以养活一个公司了.  有的叫生态圈.

  9. java中JTextPane使输出字符到指定的宽度换行,并将垂直滚动条的位置移动到输出的最后位置

    SimpleAttributeSet set = new SimpleAttributeSet(); Document doc = tp.getStyledDocument(); FontMetric ...

  10. Python - 利用pip管理包

    下载与安装setuptools和pip https://pypi.python.org/packages/source/s/setuptoolshttps://pypi.python.org/pypi ...