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. python嵌套列表

    从excel读取一行信息添加到一个临时列表,最后将所有行的列表添加到一个大列表. 源码: import xlrd,reclass Info(): def read_info(self): data = ...

  2. NOIP专题复习3 图论-强连通分量

    目录 一.知识概述 二.典型例题 1.[HAOI2006]受欢迎的牛 2.校园网络[[USACO]Network of Schools加强版] 三.算法分析 (一)Tarjan算法 (二)解决问题 四 ...

  3. day 21 03 补全异常处理

    day 21 03  异常处理(补全) 1.异常处理的整体几个语句: try: .......#有可能出错的代码 ret=int(input('number >>>')) print ...

  4. 第十八节:Scrapy爬虫框架之settings文件详解

    # -*- coding: utf-8 -*- # Scrapy settings for maoyan project## For simplicity, this file contains on ...

  5. Python爬虫例子(笔记,不适合参考,愿意看的可以看看)

    话不多说,直接上代码: import re import csv #爬虫的一个小例子,爬的是百度贴吧(网页版)某个帖子的各个楼层的用户名,发言内容和发言时间(使用到了正则表达式) source3.tx ...

  6. Lucene_Hello(示例)

    (1)创建project (2)导入Lucene的核心包 (3)编写代码建立索引 /lucene01/src/cn/hk/lucene/TestIndex.java: package cn.hk.lu ...

  7. xtu summer individual 6 B - Number Busters

    Number Busters Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...

  8. 用PowerPoint中的VB实现课件中的智能交互

    http://www.duxiushan.net/index.asp?xAction=xReadNews&NewsID=294 我们使用PPT的目的只有一个,即更好地达成“沟通.演说.汇报.讲 ...

  9. Linux读取网卡流量脚本

    #!/bin/bash #eval `date "+day=%d; month=%m; year=%Y; hour=%H; minute=%M second=%S"` #INSTF ...

  10. [bzoj1014][JSOI2008]火星人prefix_非旋转Treap_hash_二分

    火星人prefix bzoj-1014 JSOI-2004 题目大意:给定一个字符串,支持三种操作:1.查询:两个后缀之间的$LCP$:2.单点修改:3.插入一个字符. 注释:$1\le n\le 1 ...