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 ;
}
最新文章
- Effective java笔记(二),所有对象的通用方法
- SQL SERVER 2008 获取表字段的类型
- windows开机记录查询
- 浅入浅出EmguCv(二)EmguCv打开指定图片
- 【POJ2482】Stars in Your Window(线段树,扫描线)
- jQuery源代码阅读之三——jQuery实例方法和属性
- Dynamics CRM 2013 SP1 升级到Dynamics CRM 2015
- Fortran编译多个文件(转载)
- iOS NSPredicate和正则表达式
- 01-01-01【Nhibernate (版本3.3.1.4000) 出入江湖】配置文件
- Android 引用library project
- EXTJS 4.2 资料 控件GroupingGrid
- centos 6.4 Apache 配置 flv mp4.h264 流媒体拖动
- StringHelpers
- saveFileDialog
- 第8章 Android数据存储与IO——File存储
- linux下的shell和脚本
- linux_环境变量设置 utf-8
- Python常用字符编码
- #2718. 「NOI2018」归程 kruskal重构树
热门文章
- hdu3078 建层次树+在线LCA算法+排序
- a href=";javascript:void(0)";
- Spring Tool Suite (STS) 安装SVN插件
- flask的debug模式下,网页输入pin码进行调试
- HDU2897( 巴什博奕变形)
- 消息列队 分布式事务解办法 celery flower使用总结
- Android Studio 一些方便使用的设置
- 笨鸟不乖 是这么设计Android项目架构的
- 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
- Task C# 多线程和异步模型 TPL模型 【C#】43. TPL基础——Task初步 22 C# 第十八章 TPL 并行编程 TPL 和传统 .NET 异步编程一 Task.Delay() 和 Thread.Sleep() 区别