# Codeforces 414B Mashmokh and ACM (DP)

Source: Internet
Author: User

Codeforces 414B Mashmokh and ACM (DP)

Mashmokh's boss, Bimokh, didn't like Mashmokh. so he fired him. mashmokh decided to go to university and participant ipate 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 sequenceLIntegersB1 ,?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 allI(1? ≤?I? ≤?L? -? 1 ).

GivenNAndKFind the number of good sequences of lengthK. As the answer can be rather large print it modulo 1000000007 (109? +? 7 ).

Input

The first line of input contains two space-separated integersN,?K(1? ≤?N,?K? ≤? 2000 ).

Output

Output a single integer-the number of good sequences of lengthKModulo 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].

The question is the DP about the counting problem. If dp [I] [j] is set, it indicates the number of solutions whose end length is j with I: dp [I] [j] = sum (dp [k] [J-1]) (I % k = 0) Special dp [I] [1] = 1;
```#include

#include

#include#include

#include

#include

#include

#include

#include
#include

#include

using namespace std;#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )#define CLEAR( a , x ) memset ( a , x , sizeof a )typedef long long LL;typedef pair

pil;const int INF = 0x3f3f3f3f;const int MOD=1e9+7;const int maxn=2000+100;LL dp[maxn][maxn];int n,k;int main(){ while(cin>>n>>k) { CLEAR(dp,0); REPF(i,1,n) dp[i][1]=1; for(int j=1;j<=n;j++) for(int kk=j;kk<=n;kk+=j) for(int i=2;i<=k;i++) dp[kk][i]=(dp[kk][i]+dp[j][i-1])%MOD; LL ans=0; REPF(i,1,n) ans=(ans+dp[i][k])%MOD;

```

Related Keywords:
Related Article

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.