DP of the sub-sequence found in the sequence

Source: Internet
Author: User

Topic website: 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 is given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer in all. So he wasn ' t able to solve them. That's why he asked the him with these tasks. One of these tasks is the following.

A sequence Of  l  integers  b 1, b 2, ..., b l  Span class= "Tex-span" > (1≤ b 1≤ b 2≤ ... ≤ b l 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(9 + 7).

Input

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

Output

Output a single integer-the number of good sequences of length k modulo 1000000007(9 + 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 is: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

#include <stdio.h>#include<string.h>#include<iostream>using namespacestd;Const intn= .;Const intmod=1e9+7;intDp[n][n]; DP[I][J] Indicates the number of sequences of length I and the last element is J. intMain () {intn,k;  while(cin>>n>>k) {memset (DP,0,sizeof(DP));  for(intI=1; i<=n;i++) dp[1][i]=1;  for(intt=1; t<k;t++)        {             for(intI=1; i<=n;i++)            {                 for(intj=1; i*j<=n;j++) {dp[t+1][i*j]+=dp[t][i];//the DP value from the I=1 loop to the N,i*j, which is a multiple of I, plus the dp[t][i] value of the previous line (one less sequence length). Dp[t+1][i*j]%=MoD; }            }        }        int Set=0;  for(intI=1; i<=n;i++)        {            Set+=Dp[k][i]; Set%=MoD; } cout<<Set<<Endl; }    return 0 ;}

DP of the sub-sequence found in the sequence

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.