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 ...
 
随机推荐
- Jenkins设置用户权限
			
注册普通用户 系统管理-->全局安全配置---勾选允许用户注册 注册用户完成后立即关闭注册,比如我注册了(dev, test),现在我一共有3个用户,root是管理员拥有所有权限 开启授权策略 ...
 - springmvc与前端数据交互实例
			
一.从页面接收参数 Spring MVC接收请求提交的参数值的几种方法: 使用HttpServletRequest获取. @RequestMapping("/login.do" ...
 - mybatis-xml特殊字符处理
			
1. 使用CDATA区: 它的全称为character data,以"<![CDATA[ "开始,以" ]]>" 结束,在两者之间嵌入不想被解析程序 ...
 - 在PC机上,如何用Chrome浏览器模拟查看和调试手机的HTML5页面?
			
如题,如何用PC机上的Chrome浏览器模拟查看和调试手机HTML5页面? 参考操作步骤如下: 第一步.用Chrome打开要调试的页面: 第二步.按F12,打开“开发者工具”,点击其右上角的“Dock ...
 - windbg学习—-.ecxr
			
.ecxr 命令定位当前异常的上下文信息,并显示指定记录中的重要寄存器 0:000> .ecxr eax=10000000 ebx=7ffd9000 ecx=77386500 edx=002 ...
 - 【iOS微博客户端开发】1、微博整体项目的构建
			
回顾自己做过的项目,总结里面的知识点,分享自己参照WXHL的视频开发的一个模拟微博客户端的过程,为了还在IOS上找不到项目参考的朋友,这里会由一系列手把手的教程,如有不足,还希望可以抖抖小手,献上您宝 ...
 - Sublime text  JsFormat插件的安装
			
javascript格式化插件JsFormat 1.下载这插件包 https://github.com/jdc0589/JsFormat 2.点击菜单:Preferences->Browse P ...
 - WebService authentication
			
http://blog.csdn.net/largestone_187/article/details/5734632 通过SoapHeader对用户口令进行验证,只有授权的用户才可以使用接口.确保了 ...
 - easyUI中datagrid控制获取指定行数的数据
			
直接上代码: var rows=$('#detail').datagrid('getRows');//获取所有当前加载的数据行 var row=rows[0];// 行数从 0 开始 项目中代码: v ...
 - JS中的Math.pow(a,b)方法
			
定义和用法 pow() 方法可返回 x 的 y 次幂的值. 语法 Math.pow(x,y) 参数 描述 x 必需.底数.必须是数字. y 必需.幂数.必须是数字. 返回值 x 的 y 次幂. 说明 ...