Codeforces Round #240 (Div. 1)---B.Mashmokh and ACM(dp)

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 and participate in ACM instead of finding a new job. He wants to become a member of Bamokh’s team. I 阅读详情

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

Note

In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

dp[i][j]表示长度为i,第i个数为j的方案数

/*************************************************************************
    > File Name: cf-240-div1-B.cpp
    > Author: ALex
    > Mail: zchao1995@gmail.com 
    > Created Time: 2015年06月02日 星期二 12时35分58秒
 ************************************************************************/

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <vector>

using namespace std;

const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
typedef long long LL;
typedef pair <int, int> PLL;

static const int mod = 1000000007;
LL dp[2010][2010];

int main() {
    int n, k;
    while (cin >> n >> k) {
        memset(dp, 0, sizeof(dp));
        for (int i = 1; i <= n; ++i) {
            dp[1][i] = 1;
        }
        for (int i = 1; i < k; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (!dp[i][j]) {
                    continue;
                }
                for (int l = j; l <= n; l +=j) {
                    dp[i + 1][l] += dp[i][j];
                    dp[i + 1][l] %= mod;
                }
            }
        }
        LL ans = 0;
        for (int i = 1; i <= n; ++i) {
            ans += dp[k][i];
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}
嵌入式工程师成长之路(7)——算法学习 算法大全1、风仲达——算法笔记2、坐在马桶上学算法3、啊哈算法4、深度强化学习实验室。 阅读详情

相关推荐

TI毫米波雷达人体生命体征(呼吸、心跳)信号提取算法(IWR6843ISK+DCA1000EVM)

本篇内容介绍的算法主要为传统的提取算法,但可实现在1m内呈现良好的检测效果,能够提取出非常可观的呼吸和心跳波形,但在超出1m的距离后便不适用这个算法了。远距离检测呼吸和心跳始终是这个领域一个很大的挑战。要实现远距离检测可在提取相位信号、分离呼吸和心跳信号上进行改进处理,例如线性解调提取相位、改进的VMD分离呼吸和心跳算法。

m0_61934621的博客 3万+

CodeForces - 414B Mashmokh and ACM(dp)

题目链接:https://vjudge.net/problem/CodeForces-414B 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

zaiyang遇见 686

自建智能算力中心与第三方算力租赁的深度分析

自建智算中心和第三方算力租赁的主要区别如下:对比维度自建算力中心第三方算力租赁初期成本数千万至数亿元硬件采购+机房基建零硬件投入,按需付费(如1元/卡时)部署速度6-12个月(采购、部署、调试)即时开通,分钟级资源调度运维难度需专业IT团队,承担断电、故障等风险服务商全托管,SLA保障99.95%可用性弹性扩展扩容需重新采购硬件,周期长、成本高支持秒级弹性伸缩,应对流量峰值技术迭代硬件更新周期长,易被淘汰自动升级。

2501_90999758的博客 2357

第六周Mashmokh and ACM(Dp Y)

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

m0_51506743的博客 281

Hyper-V创建Ubuntu虚拟机设置固定IP

本文记录使用hyper-v创建ubuntu虚拟机,为虚拟设置固定IP且通过物理机可访问。

2623

游戏安全逆向实战:如何用010Editor绕过ACE反作弊的文件校验(附详细步骤)

本文详细介绍了如何通过逆向工程思维和010Editor工具,针对PC游戏中ACE反作弊系统的文件校验机制进行分析与绕过。文章以实战案例为核心,逐步拆解了定位校验逻辑、解析校验数据文件、计算并替换哈希值的关键步骤,为安全研究人员提供了一种在用户态(Ring 3)层面进行轻量化对抗的思路与方法。

iii12的专栏 732

B. Mashmokh and ACM

414B. Mashmokh and ACM:题目 1400分就进入经典dp了 题意:给你1-n的数,构造一个长度为k的串,后一个数能整除前一个数 #include <bits/stdc++.h> using namespace std; #define int long long vector<int> a((int)6e5); vector<int> b((int)6e5), c((int)6e5); const int mod = 1e9 + 7; signed

weixin_51771856的博客 198

Open3D 使用RANSAC分割平面【2026最新版】

使用RANSAC从点云中分割平面,用segement_plane函数。博客长期更新,本文最新更新时间为:2026年2月28日。

点云侠的博客 37万+

补几道题

一直忙着复习,所以好久好久没写题解了。 暑假集训开始了,开始写题解吧,顺便有自己的一个计划,会在博客中体现的: cf #240 div2 D2016 Al-Baath University Training Camp Contest-1 I. March Rain J   X and Beasts

qq_24664053的博客 349

【软件使用】向日葵网络连接错误

一直报这个错误,尝试了修改版本无果,各种密码都正确,最后得出结轮是时间没有同步,查看代理是否更改了时间,做一下同步即可。

andeyeluguo的博客 7975

27930-2015+充电协议解析

对2015+充电与2015充电进行硬件电路对比、通信协议对比和2015+通信协议解析。

manjixingkong1234的专栏 236

Mashmokh and ACM CodeForces - 414B 【DP】

B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mas

Haipai1998的博客 380

麒麟系统无法进入单用户模式该怎么办?

🏆本文收录于《全栈Bug调优(实战版)》专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 备注:部分问题/疑难杂症搜集于互联网。

**My Coding Family** 1820

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

B. Mashmokh and ACM time limit per test ...

weixin_30432179的博客 140

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces Round #240 (Div. 1) 前3题 解题报告

Codeforces Round #240 (Div. 1) A. Mashmokh and Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard ou

SF-_- 的 ACM 博客 1365

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces Round #240 (Div. 1) B. Mashmokh and ACM(dp&排列组合)

 题意:输入两个数n和k,从1-n这个数中选择不超过k个数组成一个序列,每个数可以选多次,组成的序列每个数可以整除前一位数,问可以组成多少个这种序列。 #include&lt;bits/stdc++.h&gt; using namespace std; const long long mod=1e9+7; int dp[2010][2010]; int main(){ int n,k;...

samscream的博客 194

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces Round #240 (Div. 1)B

B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mas

虽千万bug吾往 495

Codeforces Round #240 (Div. 2) D. Mashmokh and ACM

#include #include using namespace std; const int N=2009; const int M=1e9+7; typedef long long ll; int dp[N][N]; int main(){ int i,j,k,n,m,x,y,T; scanf("%d%d",&n,&k); for(i=1;i<=n;i++)

a370802的专栏 487

Codeforces Round #240 (Div. 2) D

D. Mashmokh and ACMMashmokh'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. H...

weixin_30687811的博客 82

Codeforces Round #240 (Div. 2)(D:dp递推)

A - Mashmokh and Lights

龙崎的专栏 578

【菜笔cf刷题日常-1400】B. Mashmokh and ACM(动态规划)

其中 i 代表序列长度,j 代表最后一位数。

IamDickman的博客 255

B. Mashmokh and ACM(cf)dp

原题链接:Problem - 414B - Codeforces 题目大意:给出两个数n,k,可以取1~n中的数,组成长度为k的数组,数组满足a1 <= a2 <= ..<= ak,且相邻两数满足前面这个数可以除尽后面那个数ai +1 % ai == 0.问你有多少种情况。 一开始我想的是完全背包,因为1~n中的数可以用不止一次,但是限制是个数,我又觉得无从下手了。参考了其他大佬的代码,最后总结出来: 可以令数组dp【i】【z】//i表示当前数组长度,z表示以z值作为最后一个数的情

qq_52313416的博客 258

Codeforces#414B——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. I

琳小白的博客 815
上一篇: POJ1337---A Lazy Worker(dp)
下一篇: hdu2227---Find the nondecreasing subsequences(dp+树状数组)
tokers
博客等级 码龄12年 71粉丝 700原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值