Codeforces Round #240 (Div. 2) D
D. Mashmokh and ACM
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
6 4
39
2 1
2
题意:给出一组数列,问满足数列递增且前一个元素能整除后一个元素的数列一共有多少种。
sl:赤裸裸的dp,比赛时叫C整的快没时间了,十分钟敲了下交了一发wa了原来忘记mod1e9了。
dp方程: dp[i][j]+=dp[i-1][k] (j%k==0) 只要预处理因子就可以了。
1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #include<vector>
5 using namespace std;
6 const int MAX = +;
7 const int MOD = 1e9+;
8 int dp[MAX][MAX];
9 vector<int> v[MAX];
void init()
{
memset(dp,,sizeof(dp));
for(int i=;i<MAX;i++) dp[][i]=;
for(int i=;i<MAX;i++)
{
for(int j=;j<=i;j++)
{
if(i%j==) v[i].push_back(j);
}
}
}
int main()
{
int n,k;
init();
scanf("%d %d",&n,&k);
for(int j=;j<=n;j++)
for(int i=;i<=k;i++)
{
for(int m=;m<v[j].size();m++)
{
dp[i][j]=(dp[i][j]+dp[i-][v[j][m]])%MOD;
}
}
int ans=;
for(int i=;i<=n;i++) ans=(ans+dp[k][i])%MOD;
printf("%d\n",ans%MOD);
return ;
39 }
Codeforces Round #240 (Div. 2) D的更多相关文章
- 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)(A -- D)
点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...
- 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. 1) B. Mashmokh and ACM DP
B. Mashmokh and ACM ...
- 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 #240 (Div. 2) 题解
A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- bzoj 1801: [Ahoi2009]chess 中国象棋【dp】
注意到一行只能放012个炮,我们只需要知道列的状态,不用状压行 所以设f[i][j][k]表示前i行有j列有1个炮,有k列有2个炮的方案数 然后分情况讨论转移就行了 #include<cstdi ...
- 慕课网JavaScript函数1-20 作业:函数的基础封装
1-20 作业 小伙伴们,掌握了JavaScript的语法.流程控制语句以及函数,接下来让我们运用所学知识完成如gif图所示的效果——计算自己出生那天是该年当中的第几天. gif效果图如下: 任务描述 ...
- P4451 [国家集训队]整数的lqp拆分
#include <bits/stdc++.h> using namespace std; typedef long long LL; inline LL read () { LL res ...
- rman 问题
1. RMAN Repeatedly Fail To Backup Archivelogs with RMAN-20242 Cause: There is a mis-match between th ...
- python调用chrome ie等浏览器
chrome: 首先,要安装下谷歌浏览器,查看谷歌浏览器的版本,对应版本下载相应的chromedriver插件,http://blog.csdn.net/huilan_same/article/det ...
- VS2013使用单元测试
一.开发环境 开发工具:VS2013 二.开发流程 1.添加一个控制台项目UnitDemo namespace UnitDemo { public class Program { static voi ...
- [ Nowcoder Contest 167 #D ] 重蹈覆辙
\(\\\) \(Description\) 用\(1\times 2\)的矩形和面积为\(3\)的\(L\)形去覆盖一个\(2\times N\) 的矩形,求方案数对\(10^4+7\)取模后的结果 ...
- cocos2dx使用lua和protobuf
为了使游戏开发更加方便快捷,我继续了protobuf在lua下的尝试. socket使用的是cocos2dx集成的websocket. 先说下环境:cocos2d-x-2.2.1 + protobuf ...
- 内存溢出及Jvm监控工具
内存泄露与内存溢出 内存溢出 out of memory,是指程序在申请内存时,没有足够的内存空间供其使用,出现out of memory. 内存泄露 memory leak,是指程序在申请内存后,无 ...
- 导入RPA应该了解的一些知识
上次概要介绍了下RPA的基本知识,这次说一下导入RPA时应该知道的一些知识点. RPA是为了实现用软件自动化代替在各个行业中用人操作电脑办公的这部分业务,即使是在多个应用之间需要共享数据才能完成的业务 ...