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. A brief preview of the new features introduced by OpenGL 3.3 and 4.0

    A brief preview of the new features introduced by OpenGL 3.3 and 4.0   The Khronos Group continues t ...

  2. mybatis编写mapper操作

    mybatis编写mapper resultType和resultMap resultType可以直接指定返回类型,例如自定义的bean  <!--通过账号查询用户:一个参数用parameter ...

  3. VF 查表

    题目的意思就是 给你一个数字 n (1~81)  然后问你从 1~10^9  之中有多少个 各位数字之和等于 n 的 数字 我上去   打表了  而且速度还差不多 , 能在 几十分钟内算出来所有答案 ...

  4. 二分图最大匹配(匈牙利算法) UVA 10080 Gopher II

    题目传送门 /* 匈牙利算法:这题比UVA_670简单,注意是要被吃的鼠的最少个数,套模板 */ #include <cstdio> #include <algorithm> ...

  5. S - Cyclic Components (并查集的理解)

    Description You are given an undirected graph consisting of nn vertices and mm edges. Your task is t ...

  6. Python基础:基本数据类型

    python基本标准6类数据类型:Number数字, String字符串, List列表,Tuple元组,Set集合,Dictionary字典 不可变数据3个(Number数字,String字符串,T ...

  7. python对象以及pickle腌制

    #python对象 1.什么是python的对象 2.详解pickle腌制 1.什么是python的对象 Python的内置的对象类型主要有数字.字符串.列表.元组.字典.集合等等.其实,在pytho ...

  8. 主库binlog(master-log)与从库relay-log的关系

    主库binlog: # at # :: server id end_log_pos CRC32 COMMIT/*!*/; # at # :: server id end_log_pos CRC32 e ...

  9. 7z.exe 命令行压缩文件排除文件(exclude filenames) 手记

    命令行使用格式:Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] ...

  10. IOS 11,UIWebView内容随状态栏高度下移,导致状态栏不透明

    解决方案: 方法1:在html中设置 <meta name="viewport" content="viewport-fit=cover,maximum-scale ...