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 ;
}

代码

最新文章

  1. fir.im Weekly - TouchBar 从入门到开发
  2. 第9章 Java类的三大特性之一:继承
  3. const、static、extern三个关键字
  4. 关于mysql jsp字符编码的问题解决
  5. 在一个JSP页面中包含另一个JSP页面的三种方式
  6. 集合类 Contains 方法 深入详解 与接口的实例
  7. 【SQL Server】SQL与Excel的数据互通导入导出
  8. linux下C语言socket网络编程简例
  9. 禁用掉用户帐号,用户Lync客户端仍然可以登录!
  10. Android 记录的(MediaRecorder)而播放(MediaPlayer)
  11. Unity中www的基本应用
  12. linux logrotate配置
  13. MYSQL数据库-约束
  14. 二:Redis快速入门及应用
  15. SSL/TLS通信
  16. 如何开发由Create-React-App 引导的应用(四)
  17. 安装xgboost
  18. Jenkins部署码云SpringBoot项目到远程服务器
  19. 【Scheme】树结构
  20. Leetcode:LRU Cache,LFU Cache

热门文章

  1. Python3中assert断言
  2. ios中摄像头/相册获取图片压缩图片上传服务器方法总结
  3. 简单的linux看门狗脚本
  4. 树莓派 -- 输入设备驱动 (key) 续2: 转载 Setting up a GPIO-Button “keyboard” on a Raspberry Pi
  5. Python之Pycharm安装及介绍
  6. package control(转载)
  7. codeforces 330b
  8. POJ 1988相对偏移
  9. Linux下汇编语言学习笔记36 ---
  10. [bzoj1324]Exca王者之剑_最小割