题目链接:

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

codeforces 414B B. Mashmokh and ACM(dp)的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP

                                                 B. Mashmokh and ACM                                     ...

  3. B. Mashmokh and ACM(dp)

    http://codeforces.com/problemset/problem/414/B B. Mashmokh and ACM time limit per test 1 second memo ...

  4. [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)

    [Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...

  5. [CodeForces - 1225E]Rock Is Push 【dp】【前缀和】

    [CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory ...

  6. [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)

    [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...

  7. Codeforces 414B Mashmokh and ACM

    http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...

  8. codeforces D.Mashmokh and ACM

    题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...

  9. CodeForces 415D Mashmokh and ACM

    $dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{}  {dp[i - 1][k]}$ ...

随机推荐

  1. Linux 环境下思源黑体字体与 Java 之间的兼容性问题的解决(补充说明)

    在前一篇随笔中,我讲了一下有关 Linux 环境下思源黑体与 Java 之间的兼容性问题,后来经过测试发现,默认安装的思源黑体字体同时包含简体字体和繁体字体,并且其对应的语言编码也是不同的.尝试着把繁 ...

  2. SSH: Transferred 0 file(s) 解决

    Jenkins搭建过程中,使用 Publish Over SSH 插件.发生 SSH: Transferred 0 file(s). 百度.google了几个小时,终于找到答案,特此记录. 配置如下: ...

  3. Js 中的输出

    document.write()和window.alert() 1.window.document.write(字符串或者是变量名) 作用:它会在body标签内输出内容 说明: window代表当前浏 ...

  4. VMware View 要求操作句柄的状态错误

    win10系统安装的VMware-viewclient,版本是

  5. T2832 6个朋友 codevs

    http://codevs.cn/problem/2832/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 有这么一种说法: ...

  6. Nginx负载均衡配置实例(转)

    1.轮询 轮询即Round Robin,根据Nginx配置文件中的顺序,依次把客户端的Web请求分发到不同的后端服务器.配置的例子如下: http{ upstream sampleapp { serv ...

  7. 【mac】mac上安装软件,报错 鉴定错误,但是安装包都是好的

    出现这个问题, 原因解析: 不是你的安装包下载出错了或者下载失败了这种原因 而是你在打开这个安装包的时候,一定是让你输入密码,而你的密码没有输入正确 解决方式:重新开始打开这个软件的安装包 如下: 1 ...

  8. IE浏览器打不开解决的方法

    windows 7和windows 8上的IE浏览器打不开.非常可能是权限问题,解决的方法: 点击"開始"-"执行",输入"regedit" ...

  9. C#语言循环语句for嵌套

  10. 基本SCTP套接字编程常用函数

    sctp_bindx函数:允许SCTP套接字捆绑一个特定地址子集 #include <netinet/sctp.h> // 若成功返回0,出错返回-1 int sctp_bindx(int ...