Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)

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 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].

dp[i][j] 长度为i,第i个数为j的方案数

/*************************************************************************
    > File Name: CF240D.cpp
    > Author: ALex
    > Mail: [email protected]
    > Created Time: 2015年03月17日 星期二 11时59分48秒
 ************************************************************************/

#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 double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
typedef long long LL;
typedef pair <int, int> PLL;

const int mod = 1000000007;
LL dp[2010][2010];

int main ()
{
    int n, K;
    while(~scanf("%d%d", &n, &K))
    {
        memset (dp, 0, sizeof(dp));
        for (int i = 1; i <= n; ++i)
        {
            dp[1][i] = 1;
        }
        for (int i = 2; i <= K; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                for (int k = 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 (int i = 1; i <= n; ++i)
        {
            ans += dp[K][i];
            ans %= mod;
        }
        printf("%lld\n", ans);
    }
    return 0;
}
时间: 2024-11-04 13:42:09

Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)的相关文章

Codeforces Round #240 (Div. 1)---B.Mashmokh and ACM(dp)

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 tas

Codeforces Round #267 (Div. 2) C. George and Job(DP)补题

Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the follow

Codeforces Round #433 (Div. 1) D. Michael and Charging Stations(dp)

题目链接:Codeforces Round #433 (Div. 1) D. Michael and Charging Stations 题意: 一个人每天要加油,1种为1000,1种为2000,如果付全额,会得到10%的回扣放在卡上. 如果卡上有剩余的回扣,可以拿来抵现金.问n天最少需要花多少钱. 题解: 很直观的一个dp就是考虑dp[i][j],表示第i天卡上剩余回扣为j的最小花费. 将所有的数除以100后,j其实是小于40的,严格的说是小于30,官方题解有个证明. 因为卡上不可能积累很多的

Codeforces Round #419 (Div. 2) E. Karen and Supermarket(树形DP)

题目链接:Codeforces Round #419 (Div. 2) E. Karen and Supermarket 题意: 有n件物品,每个物品有一个价格,和一个使用优惠券的价格,不过这个优惠券有一个限制,必须要在第x个使用后才可以使用.现在有m的钱,问最多能买多少个物品. 题解: 每个优惠券都只与一个券有关,所以根据这个关系就可以构成一棵树. 考虑树形dp,dp[i][j][k(0|1)]表示第i个节点所构成的子树中买了j个物品,使用优惠券和不使用优惠券的最少钱. 转移方程看代码详细解释

Codeforces Round #240 (Div. 2) (ABCDE题解)

题目链接:http://codeforces.com/contest/415 A. Mashmokh and Lights time limit per test:1 second memory limit per test:256 megabytes Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are index

Codeforces Round #396 (Div. 2)C. Mahmoud and a Message(dp)

题目链接:http://codeforces.com/problemset/problem/766/C 题意:给你一组小写字母组成的字符串,和26个数字,分别对应26位小写字母能够存在的字符串的最大长度. 要求:①:求出最多的划分方案 ②:求出分配方案中,最长的子串长度 ③:求出分配方案中,最少分成的子串数 思路:关于①:设置dp[i],dp[i]表示在第i个字符后面有一个横杠的方案数,从第i个往前枚举前一个横杠的位置j. 举个例子,有子串abc,当横杠断在a处,有一种方案,dp[1]=1:当横

Codeforces Round #263 (Div. 2) D. Appleman and Tree 树形dp

链接: http://codeforces.com/contest/462/problem/D 题意: 给定n个点的树, 0为根,下面n-1行表示每个点的父节点 最后一行n个数 表示每个点的颜色,0为白色,1为黑色. 把树分成若干个联通块使得每个联通块有且仅有一个黑点,问有多少种分法(结果mod1e9+7) 题解: 树形dp,每个点有2个状态,已经归属于某个黑点和未归属于某个黑点. 代码: 31 int n; 32 int x[MAXN]; 33 VI G[MAXN]; 34 ll dp[MAX

Codeforces Round #538 (Div. 2) D. Flood Fill 【区间dp || LPS (最长回文序列)】

任意门:http://codeforces.com/contest/1114/problem/D D. Flood Fill time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a line of nn colored squares in a row, numbered from 11 to nn f

Codeforces Round #337 (Div. 2) B. Vika and Squares 水题

B. Vika and Squares Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i. Vika also has an infinitely long rectangular piece of paper of width 1, consisting of s