codeforces 414B B. Mashmokh and ACM(dp)
题目链接:
1 second
256 megabytes
standard input
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).
The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).
Output a single integer — the number of good sequences of length k modulo 1000000007 (10^9 + 7).
3 2
5
6 4
39
2 1
2
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)的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP
B. Mashmokh and ACM ...
- B. Mashmokh and ACM(dp)
http://codeforces.com/problemset/problem/414/B B. Mashmokh and ACM time limit per test 1 second memo ...
- [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...
- [CodeForces - 1225E]Rock Is Push 【dp】【前缀和】
[CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory ...
- [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)
[Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...
- Codeforces 414B Mashmokh and ACM
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...
- codeforces D.Mashmokh and ACM
题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...
- CodeForces 415D Mashmokh and ACM
$dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{} {dp[i - 1][k]}$ ...
随机推荐
- 记录一下 ps命令找出线程占用cpu情况
https://blog.csdn.net/xnn2s/article/details/11865339
- Codeforces 451 E Devu and Flowers
Discription Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th ...
- matlab安装及破解
Matlab安装及破解: 笔者最近要做一些和建模相关的事,故此需要安装Matlab2017版.在此做下笔记. 网盘链接: 链接:https://pan.baidu.com/s/1lN8C7TDFjSV ...
- java 基础 5 String StringBuffer StringBuilder
String是不可变的,原因 1是可以缓存hash值,因为String的hash值经常被使用,例如String用作HashMap等.不可变特性 使得hash值不变,因此只需要进行一次计算: 2Str ...
- 成长笔记 - mysql-5.5.25-winx64安装步骤(及密码修改问题)
操作系统:Windows 7 64位 下载地址: http://download.mysql.cn/src/2012/0602/5611.html 1. 将mysql-5.5.25-winx64.zi ...
- 数据库系统学习(九)-嵌入式SQL语言之基本技巧
第九讲 嵌入式SQL语言之基本技巧 901 什么是嵌入式SQL语言 交互式SQL语言的局限性 嵌入式SQL语言 交互式和嵌入式语言的对比 高级语言中使用嵌入式语言需要解决的问题 902 程序与数据库连 ...
- hdoj-1856-More is better【并查集】
More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) To ...
- 生活娱乐 WIFI机器人(某机器发烧友自己动手做一台)
某机器发烧友自己动手做一台WIFI机器人,以下是这位发烧友的自述!让我们一起来分享他的劳动成果-- 在经历了十多天的疯狂淘宝.组装.调试.拆卸.再组装.再调试的过程后,俺的Wifi Robot终于于2 ...
- LRUCache 具体解释
LRU的基本概念: LRU是Least Recently Used的缩写,最近最少使用算法. Java 实现LRUCache 1.基于LRU的基本概念,为了达到按最近最少使用排序.能够选择HashMa ...
- CentOS安装Openfire服务
原文::http://xiao987334176.blog.51cto.com/2202382/979677 系统是全新新安装的系统.版本号是Centos 5.6 x86 同步北京时间 # ntpda ...