B. Mashmokh and ACM
                                                                                            time limit per test

1 second

                                                                                            memory limit per test

256 megabytes

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
Note

In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

题意:给你一个N,K,  表示从1到n,选取长度为k的序列A满足  Ai整除Ai-1

题解:dp[i][j]表示长度为j是最大为i的序列方案数

//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#include<set>
#include<vector>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define memfy(a) memset(a,-1,sizeof(a))
#define TS printf("111111\n");
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define FORJ(i,a,b) for(int i=a;i>=b;i--)
#define READ(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mod 1000000007
#define maxn 2005
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
ll dp[maxn][maxn]; int main()
{ int n=read(),m=read();
mem(dp);
FOR(i,,n)dp[i][]=;
FOR(k,,m-)
FOR(i,,n)
{ if(dp[i][k])
for(int j=i;j<=n;j+=i)
{
dp[j][k+]=(dp[j][k+]+dp[i][k])%mod;
}
}
ll ans=;
FOR(i,,n)ans=(ans+dp[i][m])%mod;
cout<<ans<<endl;
return ;
}

代码

Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP的更多相关文章

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

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

  3. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  4. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  5. Codeforces Round #240 (Div. 2) D

    , b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainde ...

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

  7. Codeforces Round #240 (Div. 2) B 好题

    B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standa ...

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

    A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...

  9. Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)

    Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...

随机推荐

  1. bootstrap不兼容ie8如何解决

    说起bootstrap大家一定都不陌生,可以说是目前最受欢迎的前端框架,简洁.直观.强悍.移动设备优先的前端开发框架,让web开发更迅速.简单. 但是在实际运用中也会遇到各种各样的问题,比如最近项目中 ...

  2. 珂朵莉树(Chtholly Tree)学习笔记

    珂朵莉树(Chtholly Tree)学习笔记 珂朵莉树原理 其原理在于运用一颗树(set,treap,splay......)其中要求所有元素有序,并且支持基本的操作(删除,添加,查找......) ...

  3. [0] Hello World

    受不了CSDN了,广告多,慢,编辑器难用,还限制博客数量.

  4. http返回状态码错误

    415 数据格式不正确 415 Unsupported Media Type 服务器无法处理请求附带的媒体格式 后台用json接收 1.将表单数据转换成json数据 2.设置contentType:& ...

  5. 谷歌应用商店chrome扩展程序和APP的发布流程

    互联网上有很多大牛,他们再工作中需要一些难题,再找到解决办法后,如果会使用js的话,大多数人就可以自己动手写一个chrome插件,而且非常容易.开发人员都喜欢与大家分享自己的成就!google是一个全 ...

  6. LeetCode(50) Pow(x,n)

    题目 Implement pow(x, n). Show Tags Show Similar Problems 分析 一个不利用标准幂次函数的,求幂算法实现. 参考了一个很好的解析博客:Pow(x,n ...

  7. 【XML】-- C#读取XML中元素和属性的值

    Xml是扩展标记语言的简写,是一种开发的文本格式. 啰嗦几句儿:老师布置的一个小作业却让我的脑细胞死了一堆,难的不是代码,是n多嵌套的if.foreach,做完这个,我使劲儿想:我一女孩,没有更多女孩 ...

  8. clip-path实现loading圆饼旋转效果以及其他方法

    一.loading效果 二.clip-path css中的剪切clip-path属性是CSS Masking模块的一部分. 矩形 clip-path:inset(top right bottom le ...

  9. 2014-4-5安装python以及基础知识

    1.下载安装 从python官网下载python2.7.6 https://www.python.org/download/releases/2.7.6 建议用迅雷下载 会比较快 2.交互式解释器 运 ...

  10. 添物不花钱学JavaEE(基础篇)- Servlet

    Servlet是Java Web开发必须要掌握的. Servlet是什么? A servlet is a Java technology based web component, managed by ...