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. bzoj 4756: [Usaco2017 Jan]Promotion Counting【dfs+树状数组】

    思路还是挺好玩的 首先简单粗暴的想法是dfs然后用离散化权值树状数组维护,但是这样有个问题就是这个全局的权值树状数组里并不一定都是当前点子树里的 第一反应是改树状数组,但是显然不太现实,但是可以这样想 ...

  2. EditText(4)常用属性详解

    常用的属性: 显示密码 通过设置EditText的setTransformationMethod()方法来实现隐藏密码或这显示密码. editText.setTransformationMethod( ...

  3. Generating RSA keys in PKCS#1 format in Java--转

    原文地址:https://stackoverflow.com/questions/7611383/generating-rsa-keys-in-pkcs1-format-in-java When I ...

  4. Mybatis的Dao向mapper传多个参数(三种解决方案)转自《super超人》

    第一种方案 : DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id=" ...

  5. python--12、索引知识

    MySQL索引及优化 影响性能的因素 需求:一个论坛帖子总量的统计,附加要求:实时更新.从功能上来看非常容易实现,执行一条 SELECT COUNT(*) from 表名 的 Query 就可以得到结 ...

  6. pycharm永久激活(转载)

    转载自CSDN--http://blog.csdn.net/mr_hhh/article/details/79062747 2018-02-2417:30:52 今天再补充一个教程,关于pycharm ...

  7. git删除本地分支失败,报错error: branch 'test219' not found.

    错误: 删除本地分支报错,操作如下: git branch -d test219 操作失败,错误信息:error: branch 'test219' not found git branch -D t ...

  8. Java多线程学习笔记(四)——Thread类中方法介绍

    currentThread():返回代码正在被哪个线程调用. public class CurrentThreadWay { public static void main(String[] args ...

  9. vue基础---模板语法

    Vue.js 使用了基于 HTML 的模板语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据.所有 Vue.js 的模板都是合法的 HTML ,所以能被遵循规范的浏览器和 HTML 解 ...

  10. iOS-关于一些手势冲突问题(scrollView 嵌套 tableView)

    简单说下关于开发中容易遇到的父试图添加手势与子试图点击事件冲突,UIScrollView 嵌套 UIScrollView . UIScrollView 嵌套 UITableView的情况手势冲突问题: ...