题目网址: 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. C#排序比较

    与C#定义了相等性比较规范一样,C#也定义了排序比较规范,以确定一个对象与另一个对象的先后顺序.排序规范如下 IComparable接口(包括IComparable接口和IComparable< ...

  2. Show Linux Package Sort By Size

    ArchLinux: ~ $ pacsysclean Debian: ~ $ sudo apt-get install debian-goodies ~ $ dpigs -H

  3. WPF使用扩展屏幕

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. MFC资源冲突解决方法

    AFX_MANAGE_STATE(AfxGetStaticModuleState())   先看一个例子: 1.创建一个动态链接到MFC DLL的规则DLL,其内部包含一个对话框资源.指定该对话框ID ...

  5. SharePoint 2013中以其他用户身份登录的WebPart(免费下载)

    在SharePoint 2013中微软并没有提供在SharePoint 2010中以其他用户身份登录的菜单,这对一般用户影响不大,但对于系统管理员或测试人员或特定人员(如在OA系统中的文员或秘书,常常 ...

  6. java框架篇---spring AOP 实现原理

    什么是AOP AOP(Aspect-OrientedProgramming,面向方面编程),可以说是OOP(Object-Oriented Programing,面向对象编程)的补充和完善.OOP引入 ...

  7. SNF开发平台WinForm之十二-发送手机短信功能调用-金笛-SNF快速开发平台3.3-Spring.Net.Framework

    1.调用前组装参数 2.调用发送信息服务脚本   .调用前组装参数: BaseSendTaskEntity entity = new BaseSendTaskEntity(); entity.Mess ...

  8. codeforces George and Job

    /* 题意:给一个长度为n的序列, 从中选择长度为m的k个区间(任意两个区间不会有公共部分) 使得所选择的区间的和最大! 思路:这是一种很常见的dp dp[i][j] 表示的是前 i 个数选择 j 个 ...

  9. Angular开发Tips

    1.在使用$routeProvider的时候,需要让模块依赖ngRoute,否则会提示找不到服务,示例: angular.module('module1', ['ngRoute']) .config( ...

  10. HMM 自学教程(七)前向后向算法

    本系列文章摘自 52nlp(我爱自然语言处理: http://www.52nlp.cn/),原文链接在 HMM 学习最佳范例,这是针对 国外网站上一个 HMM 教程 的翻译,作者功底很深,翻译得很精彩 ...