Codeforces Round #240 (Div. 1) B---mashmokh and ACM (water DP)

Source: Internet
Author: User

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 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, 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 is: [1,?1],? [2,?2],? [3,?3],? [1,?2],? [1,?3].

Dp[i][j] length is I, number of the number of I is J scheme

/************************************************************************* > File Name:CF240D.cpp > Autho R:alex > Mail: [email protected] > Created time:2015 March 17 Tuesday 11:59 48 seconds ********************************* ***************************************/#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;Const intMoD =1000000007; LL dp[ .][ .];intMain () {intN, K; while(~scanf("%d%d", &n, &k)) {memset(DP,0,sizeof(DP)); for(inti =1; I <= N; ++i) {dp[1][i] =1; } for(inti =2; I <= K; ++i) { for(intj =1; J <= N; ++J) { for(intK =1; K * k <= J; ++K) {if(j% k = =0) {Dp[i][j] + = dp[i-1][k] + (k * k = = j?)0: Dp[i-1][J/K]);                    DP[I][J]%= mod; }}}} LL ans =0; for(inti =1; I <= N;            ++i) {ans + = dp[k][i];        Ans%= MoD; }printf("%lld\n", ans); }return 0;}

Codeforces Round #240 (Div. 1) B---mashmokh and ACM (water DP)

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.