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: zchao1995@gmail.com
> 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;
}
Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)的更多相关文章
- Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP
B. Mashmokh and ACM ...
- Codeforces Round #240 (Div. 2)->A. Mashmokh and Lights
A. Mashmokh and Lights time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #240 (Div. 2) C Mashmokh and Numbers
, a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- 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 ...
- Codeforces Round #240 (Div. 2)(A -- D)
点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...
- Codeforces Round #240 (Div. 2) D
, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainde ...
- Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...
- Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP
D. Bad Luck Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/pr ...
随机推荐
- 洛谷——P1102 A-B数对
P1102 A-B数对 题目描述 出题是一件痛苦的事情! 题目看多了也有审美疲劳,于是我舍弃了大家所熟悉的A+B Problem,改用A-B了哈哈! 好吧,题目是这样的:给出一串数以及一个数字C,要求 ...
- RobotFramework操作浏览器滚动条
RobotFramework操作浏览器滚动条 (2016-12-21 11:52:43) 转载▼ 标签: selenium it 分类: 自动化测试 其实只要是用多了selenium+webdrive ...
- 【set】bzoj3715 [PA2014]Lustra
对每种属性开一个set,只要某个厂家符合该属性的最值,就加进set,最后判断是否有某个厂家在4个set里都存在即可. #include<cstdio> #include<set> ...
- FCL研究-集合- System.Collections 接口和对象集合
[目录] 发现自己已经有很长一段时间写代码没什么进步了,随便读读FCL的源码,看看之前一直用的方法是如何实现的,也顺便提高下自己.FCL很是庞大,很难下口,于是用最笨的办法,先看常见的命名空间,逐个展 ...
- 【OpenJudge8464】【序列DP】股票买卖
股票买卖 总时间限制: 1000ms 内存限制: 65536kB [描述] 最近越来越多的人都投身股市,阿福也有点心动了.谨记着“股市有风险,入市需谨慎”,阿福决定先来研究一下简化版的股票买卖问题. ...
- Scala实战高手****第3课:在IDE下开发第一个Scala程序纯傻瓜式彻底透彻解析
- url参数的获取
方法 function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&am ...
- 在energia中添加新的库
很多时候energia提供的库不能够满足我们的需要,这个时候我们就要自己添加库到energia中.方法如下: 在energia目录下找到hardware目录 选择对应的单片机型号文件夹进入 进入lib ...
- High Speed Inter-CHIP USB 2.0 PHY
转载:http://arasan.com/products/usb/usb-2-0/hsic-phy/ High Speed Inter-CHIP USB 2.0 PHY USB is the ubi ...
- ZooKeeper服务器是用Java创建的,它在JVM上运行。
ZooKeeper服务器是用Java创建的,它在JVM上运行. 创建配置文件 使用命令 vi conf/zoo.cfg 和所有以下参数设置为起点,打开名为 conf/zoo.cfg 的配置文件. $ ...