题目链接:

B. Mashmokh and ACM

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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(10^9 + 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 (10^9 + 7).

Examples
 
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].

题意

给出这么多数[1,n],问能形成长为l的数列满足b[i]|b[i+1]的方案数;

思路

dp[i][j]表示长为i,以j结尾的方案数,

dp[i+1][j]=∑dp[i][k],k为j的因数;

AC代码

#include <bits/stdc++.h>
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int N=2e5+;
LL dp[][];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)
{
dp[][i]=;
}
for(int i=;i<=k;i++)
{
Rjep(n)
{
for(int x=;x*j<=;x++)
{
dp[i+][x*j]+=dp[i][j];
dp[i+][x*j]%=mod;
}
}
}
LL ans=;
for(int i=;i<=n;i++)
{
ans+=dp[k][i];
ans%=mod;
}
cout<<ans<<"\n"; return ;
}

最新文章

  1. Effective java笔记(二),所有对象的通用方法
  2. SQL SERVER 2008 获取表字段的类型
  3. windows开机记录查询
  4. 浅入浅出EmguCv(二)EmguCv打开指定图片
  5. 【POJ2482】Stars in Your Window(线段树,扫描线)
  6. jQuery源代码阅读之三——jQuery实例方法和属性
  7. Dynamics CRM 2013 SP1 升级到Dynamics CRM 2015
  8. Fortran编译多个文件(转载)
  9. iOS NSPredicate和正则表达式
  10. 01-01-01【Nhibernate (版本3.3.1.4000) 出入江湖】配置文件
  11. Android 引用library project
  12. EXTJS 4.2 资料 控件GroupingGrid
  13. centos 6.4 Apache 配置 flv mp4.h264 流媒体拖动
  14. StringHelpers
  15. saveFileDialog
  16. 第8章 Android数据存储与IO——File存储
  17. linux下的shell和脚本
  18. linux_环境变量设置 utf-8
  19. Python常用字符编码
  20. #2718. 「NOI2018」归程 kruskal重构树

热门文章

  1. hdu3078 建层次树+在线LCA算法+排序
  2. a href=&quot;javascript:void(0)&quot;
  3. Spring Tool Suite (STS) 安装SVN插件
  4. flask的debug模式下,网页输入pin码进行调试
  5. HDU2897( 巴什博奕变形)
  6. 消息列队 分布式事务解办法 celery flower使用总结
  7. Android Studio 一些方便使用的设置
  8. 笨鸟不乖 是这么设计Android项目架构的
  9. 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
  10. Task C# 多线程和异步模型 TPL模型 【C#】43. TPL基础——Task初步 22 C# 第十八章 TPL 并行编程 TPL 和传统 .NET 异步编程一 Task.Delay() 和 Thread.Sleep() 区别