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).

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 (109 + 7).

Sample test(s)
input
3 2
output
5
input
6 4
output
39
input
2 1
output
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的更多相关文章

  1. 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 ...

  2. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  3. 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 ...

  4. Codeforces Round #240 (Div. 2) B 好题

    B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standa ...

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

                                                 B. Mashmokh and ACM                                     ...

  6. 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 ...

  7. Codeforces Round #240 (Div. 2) 题解

    A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...

  8. 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 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. Vue学习-Element框架

    今天学了一个基于Vue2.0的桌面端组件库Element,号称是全世界最流行的Vue UI框架.感觉学会了之后就变身大牛了有木有. 好了,不吹牛皮了. Element官方文档通俗易懂,框架什么的安装引 ...

  2. Troubleshooting Guide for ORA-12541 TNS: No Listener

    Server side checks (not platform specific): 1)  Check the result on the server using tnsping to the ...

  3. 300 Longest Increasing Subsequence 最长上升子序列

    给出一个无序的整形数组,找到最长上升子序列的长度.例如,给出 [10, 9, 2, 5, 3, 7, 101, 18],最长的上升子序列是 [2, 3, 7, 101],因此它的长度是4.因为可能会有 ...

  4. shell set理解

    在spark bin下面load-spark-env.sh脚本里,有以下语句: if [ -f "${user_conf_dir}/spark-env.sh" ]; then # ...

  5. .Net MVC 前台验证跟后台验证

    前台验证: 首先你得有一个参数类,参数类代码如下 验证标记总结 [DisplayName("邮箱:")]        [Required(ErrorMessage = " ...

  6. Android基础TOP5_2:MultiAutoCompleteTextView多文本自动补全文本框

    Activity: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...

  7. Tcl之Read files for synthesis

    The following file is to read all design files into syntehsis tool automatically, like Cadence RTL C ...

  8. ORA-01033:ORACLE initialization or shutdown in process

    Oracle遇到问题 :在PL/SQL当输入用户名和密码后 竟然出现标题上错误,我一项目数据库数据库全都没有备份,还有很多很多数据,该不会让我重装数据库吧,想到这个我汗那个流啊. 在网上查了下 看了看 ...

  9. ubuntu服务器全部署

    一.nginx+php+redis+phpredis 二.安装mysql 三.上传web文件 cd /var mkdir www cd www/ mkdir html cd html/ rz (apt ...

  10. 通过Maven将指定Jar包下载到指定的本地目录

    现在大家大部分都通过Maven等工具来管理包,但是特殊情况下还是需要将包下载到本地.我们可以通过maven命令来完成这个需求.创建一个pom.xml文件,文件内容如下: <?xml versio ...