Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP
1 second
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).
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 (109 + 7).
3 2
5
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 ;
}
代码
Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP的更多相关文章
- Codeforces Round #240 (Div. 2)->A. Mashmokh and Lights
A. Mashmokh and Lights time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #240 (Div. 2) C Mashmokh and Numbers
, a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #240 (Div. 2)(A -- D)
点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...
- Codeforces Round #240 (Div. 2) D
, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainde ...
- Codeforces Round #240 (Div. 1)B---Mashmokh and ACM(水dp)
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university ...
- Codeforces Round #240 (Div. 2) B 好题
B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #240 (Div. 2) 题解
A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...
随机推荐
- python 语法之 装饰器decorator
装饰器 decorator 或者称为包装器,是对函数的一种包装. 它能使函数的功能得到扩充,而同时不用修改函数本身的代码. 它能够增加函数执行前.执行后的行为,而不需对调用函数的代码做任何改变. 下面 ...
- BZOJ 3144 切糕 最小割
题意: 一个矩阵,每个格子分配一个数,不同的数字,代价不同,要求相邻格子数字差小等于d 求最小代价. 分析: 我猜肯定有人看题目就想到最小割了,然后一看题面理科否决了自己的这个想法…… 没错,就是最小 ...
- 如何使用 Laravel Collections 类编写神级代码
本文首发于 如何使用 Laravel Collections 类编写神级代码,转载请注明出处. Laravel 提供了一些超赞的组件,在我看来,它是目前所有 Web 框架中提供组件支持最好的一个.它不 ...
- Altium designer中生成gerbera文件
在Altium designer中生成gerbera文件的方法有很多,不同版本,差异行不太大,正如下边链接地址里博主在10版本下的方法,在6.0版本长也是这样 http://blog.sina.com ...
- 找到多个与名为“Home”的控制器匹配的类型。
原因分析 其实上面已经讲的很清楚了,找到了两个同名Home控制器,需要配置命名空间来区分. 解决方法 方法一:修改RouteConfig.cs 方法二:修改RouteConfig.cs 和 Admin ...
- 关于Filter中ServletRequest和ServletResponse强转HttpServletRequest和HttpServletResponse安全问题(向下转型一定不安全吗?)
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOE ...
- pip提示Did not provide a commend
今天小编想要查看一下自己安装的pip版本,并且使用pip查看selenium版本等,结果在cmd输入pip,提示Did not provide a commend,如下所示: 在网上查询了很多方法,比 ...
- BNUOJ 7697 Information Disturbing
Information Disturbing Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on HDU. ...
- hdu 4771好题
#include<stdio.h> #include<string.h>//通过只记录每一步此时点的状态.题非常好 #include<queue> using na ...
- msp430入门学习06
msp430的IO端口的第一功能 msp430入门学习