数位DP小记 + HDU 2089 不要62

手把手教你配置MAX96712解串器:从I2C地址分配到PWM帧同步 本文详细解析了MAX96712解串器在自动驾驶视觉链路中的核心配置流程。从I2C地址分配、GMSL2数据流映射到实现多摄像头精准同步的PWM帧同步触发,手把手指导工程师构建高可靠性的图像传输系统,并提供了实用的Linux调试技巧与问题排查思路。 阅读详情

【背景】

如何求出在给定区间[A,B]内,符合条件P(i)的数i的个数?
条件P(i)一般与数的大小无关,而与 数的组成有关,有一下几种P(i):
数i是递增/递减的:1234, 2579,…
双峰的:19280,26193,…
含/不含某一数字的,比如含49:49, 149, 1492,…  (见下方例题)
被某一数m整除的,比如m=13:39,130,650...  (见 Codeforces 410D Roman and Numbers )

【思路】

采用记忆化搜索实现。

搜索:dfs(i,j,k,ismax)

枚举第i位的数,匹配str[j],前一位是k,是否达到上限(ismax=true/false)
达到了上限只能统计cnt=sum(0~num[i]),否则可以统计cnt=sum(0~9)
记忆:return ismax ? cnt : dp[i][j][k] = cnt
为何这么做见下方代码注释
搜索入口:dfs(len,-1,-1,true)

【例题】


这题的P(i)是不含有4和62的数,那么只需dfs(i,is6,ismax)即可,表示当前搜索到第i位,前一位是否为6(因为要判断后面那个是否为2),是否达到上限。记忆dp[i][ismax],搜索入口为dfs(len,false,true)


完整代码:

/*15ms,232KB*/

#include<cstdio>
#include<cstring>
const int mx = 10;

int bit[mx], dp[mx][2];

///复杂度O(log n)
///若ismax为true则后面循环的时候i只能取0~bit[len]
///is6记录上一位是否为6
int dfs(int len, bool is6, bool ismax)
{
	if (len == 0) return 1; ///能递归到这里说明这串数符合要求,返回1
	if (!ismax && dp[len][is6] >= 0) return dp[len][is6];
	///若ismax为true,则还需要继续向下递归
	///为什么?对于n=5321来说,递归中的2xxx和3xxx可以直接在len=3时返回(因为xxx这颗子树已经被前面的1xxx算出来了)
	///但是在算5xxx时并不能直接返回,因为后面的xxx至多能取到321,还需要进一步往下递归
	int cnt = 0, maxnum = (ismax ? bit[len] : 9);
	for (int i = 0; i <= maxnum; ++i)
	{
		if (i == 4 || is6 && i == 2) continue; ///不能有4,或者前一位为6且该位为2
		cnt += dfs(len - 1, i == 6, ismax && i == maxnum); ///ismax && i == maxnum 用来判断是否达到位值上限
	}
	return ismax ? cnt : dp[len][is6] = cnt; ///根据ismax来决定是否记录dp(比如dp[3][1]记录的是6xx的所有数,即从600到699中的符合条件的数的个数)
}

int f(int n)
{
	int len = 0;
	while (n)
	{
		bit[++len] = n % 10;
		n /= 10;
	}
	return dfs(len, false, true); ///从首位开始递归统计
}

int main()
{
	int a, b;
	memset(dp, -1, sizeof(dp));
	while (scanf("%d%d", &a, &b), a)
		printf("%d\n", f(b) - f(a - 1));
	return 0;
}


转载请注明:http://blog.youkuaiyun.com/synapse7/article/details/21006265

vivado运行时报错 license文件更新操作 vivado使用:SYNTHESIS->Run Synthesis 时报错 [Common 17-345] A valid license was not found for feature ‘Synthesis’ and/or device ‘xc7vx485t’. Please run the Vivado License Manager for assistance in determiningwhich features and devices are licensed for your sy 阅读详情

相关推荐

在摩尔线程 MTT S80 上使用 Ollama 进行 DeepSeek R1 蒸馏版模型推理

本文主要介绍了如何在摩尔线程 MTT S80 上通过 Ollama 快速完成DeepSeek R1 蒸馏系列模型的推理。

摩尔线程blog中心 3597

[HDU - 2089] 不要62 (动态规划 && 数位dp)

Link:http://acm.hdu.edu.cn/showproblem.php?pid=2089 不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 50093    Accepted Submission(s)

Hello Joanna 512

点云直线检测-3DLineDetection复现

点云直线分割-Fast 3D line detection

阁楼 8156

HDU 2089 不要62(数位DP,三种姿势)

HDU 2089 不要62(数位DP,三种姿势) ACM 题目地址:HDU 2089 题意:  中文题意,不解释。 分析: 100w的数据,暴力打表能过先初始化dp数组,表示前i位的三种情况,再进行推算直接dfs,一遍搜一变记录,可能有不饥渴的全部算和饥渴的部分算情况,记录只能记录全部算(推荐看∑大的详细题解Orz) 代码:  1. 暴力 (以前写的)

水果君の日常 9355

Hopf振荡器在机器人步态控制里到底怎么用?一个CPG仿生案例说清楚

本文深入解析了Hopf振荡器在机器人步态控制中的实际应用,通过CPG仿生案例详细展示了从数学方程到关节指令的完整流程。重点探讨了Hopf振荡器的极限环稳定性、参数调节技巧及自适应控制策略,为机器人运动控制提供了高效解决方案。

weixin_29284657的博客 200

从UART到RS485:手把手教你用SIT3485E收发器搞定工业级通信(含原理图与PCB布局要点)

本文详细解析了从UART到RS485的工业级通信转换,重点介绍了SIT3485E收发器的原理图设计、PCB布局要点及抗干扰技巧。通过差分信号传输和优化电路设计,实现长距离、多设备稳定通信,适用于工业自动化等复杂环境。

weixin_29169505的博客 349

几个基础数位DP (hdu 2089,hdu 3555 ,uestc 1307 windy 数)

转载请注明出处,谢谢 http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents           by---cxlove 做了几个非常基础的数位DP,很水。弱爆了,接下来要进行进阶训练了 HDU 2089 不要62 http://acm.hdu.edu.cn/showproblem.php?pid=2089 不能出现4,或者相邻的62,这

窝不是爱酱,喵~~~~ 1万+

YOLOv11改进策略【模型轻量化】| 替换骨干网络为 GhostNet V3 2024华为的重参数轻量化模型

一、本文介绍 本文记录的是基于 GhostNetV3 的 YOLOv11 轻量化改进方法研究。GhostNetV3的轻量模块采用重参数化方法,训练时为深度可分离卷积和1×1卷积添加线性并行分支,推理时通过逆重参数化移除分支、折叠操作,能够在不增加推理成本的同时提高性能,从而实现YOLOv11的轻量化改进。 专栏目录:YOLOv11改进目录一览 | 涉及卷积层、轻量化、注意力、损失函数、Backbone、SPPF、Neck、检测头等全方位改进 专栏地址:YOLOv11改进专栏——以发表论文的角度,快速

Limiiiing的博客 1845

不要62 HDU - 2089 (数位d'p)

不要62 HDU - 2089 题意:给出L和R,问在L到R区间内有多少数,数内没有4和62. 思路:这道题的数据范围不是很大,可以直接打表,但是也可以按照数位dp的做法,p[len]记录数的每一位。dfs()进行搜索,len表示当前到哪一位,six表示前一位是不是6,flag判断这个数是不是边界数,记录已经搜索的dp[len][six]. 对于搜索2358 当前在3的时候 对于那个fo...

DeathYmz的博客 1459

配置 SAP Fiori 服务的 ICF 节点:从 SICF 激活到访问链路打通的完整实践

在SAP Fiori项目实施中,ICF节点配置是关键前置条件却常被忽视。ICF(Internet Communication Framework)作为HTTP请求入口,需要通过SICF事务码激活相关服务节点,否则即使应用开发完善,用户仍可能遇到页面无法访问等问题。典型问题表现为:磁贴可点击但页面空白、资源加载失败等。激活路径主要涉及三组节点:bsp分支下的管理入口、ui5_ui5分支下的应用资源,以及public/bc下的公共资源。项目实施中需特别注意同名服务在不同分支下的差异化作用,确保完整链路通畅。IC

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 264

基于Simulink的固态变压器(SST)多级协同控制​

本文介绍了基于Simulink的固态变压器(SST)多级协同控制方法。SST作为智能电网关键设备,其三级架构(AC-DC整流、DC-DC隔离、DC-AC逆变)存在级间耦合问题。文章提出纵向解耦与横向联动相结合的协同控制策略,详细推导了各级控制算法,并通过Simulink实现了10kV/400V级联型SST系统建模。仿真结果显示,在±20%电网波动和0-100%负载跳变下,系统能保持直流母线电压波动<2%。文章还提供了工程部署建议和代码生成方法,为SST的研发提供了实用指导。

amy_mhd的博客 301

【数位DP】 hdu2089 不要62

不要62 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意:问在n,m之间不含4和62序列(4和62为不吉利数)的数字有多少个。 题解:把状态分为3种,1)不包含不吉利数且末位不为6。2)不包含不吉利数且末位为6。3)包含不吉利数。 状态转移见代码注释。              ps:不看讨论说这题打表也能过。 代码: #i

Ted's 游乐园 4768

c#【保姆级教程】基于System.Text.Json 支持多态类型序列化! 手把手教你实现一个通用的 PolymorphicJsonConverter!

我们需要自己实现一个继承自的转换器,在序列化时记录具体类型,在反序列化时根据类型标识还原成正确的子类对象。public abstract class WorkStepBase { /* 抽象方法等 */ }public class Person : WorkStepBase { /* 实现 */ }public class Product : WorkStepBase { /* 实现 */ }特性说明✅ 自动发现子类无需手动维护类型列表,自动扫描程序集✅ 类名映射。

一个编程的同学 425

[HDU-2089] 不要62(数位dp模板题)

题目链接: 不要62 大致题意: 给一个区间,统计区间中不含4和62的数字个数 解题思路: 对于1e9的数据,可以用数位dp来做 对于区间求个数,通常套路是dp®-dp(l-1)求[l,r]区间的数字个数 f[i][j] 表示填到第i位,当第i位填j的时候有多少种合适的数字 分解每一位,从最高位开始判断,累加上所有满足条件的数字个数 特判一下0 AC代码: #include<iostream> #include<algorithm> #include<cstring&gt

qq_49494204的博客 543

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

数位DP入门 —— hdu2089 不要62

数位DP是一种用来计数的DP, 如果给你一道题, 让你去统计区间[l, r]之间满足某种条件的数字个数, 在没接触数位之前很容易想到的就是暴力判断。但当数据范围较大时这种方法就不可行了, 这时候我们就可能要用的差分的思想确定一个递推关系, 来更方便更高效的求解, 这就是数位DP。这种理论的东西可能写出来帮助不大, 数位DP的思想是通过自己对问题的思考逐渐建立的, 下面是我选的一个例题来帮助初步理解...

Kruskal的博客 497

深度学习工具包 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'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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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, 'Too big error');```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('state',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, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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, 'Too big error');%% ex3 neural net with dropoutrand('state',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, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数位dp——hdu2089不要62

刚开始接触数位dp,看其他的博客和教程也不是很懂,不过学习就是一个循序渐进的过程嘛๑乛◡乛๑ 下面简单写写入门级的hdu2089不要62 中途找到一个比较好的ppt,我觉得讲的还是很清楚的了->初探数位dp (下面的过程咋一看不明白可以把中间的过程打印出来,我是这样做的,感觉初学很见效) 1、预处理 dp[i][j]代表首位为j的i位数里符合条件(不含62和4)的数的个数...

187

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

【数位DP】HDU 2089 不要62

HDU 2089 不要62 题意: 求[n, m]中没有连续62并且没有4的数的个数。 其中n和m的范围是1e6 解: 其实最关键的部分就是dfs的部分。 首先我们将每个数位的值保存在一个数组里。 解释一下dfs参数的意义: pos:第几个数位。例如100,pos分别为2,1,0 pre:高一位数位的值。例如67,数位0的高一位数位是1,值为6。(它存在的意义是因为62连续是不合法的) st...

L_X_ 236

数位DP 记忆化搜索 不要62HDU2089(java实现)

数位dp数位dp = dfs + 记忆化主要思路HDU2089 AC代码 数位dp = dfs + 记忆化 主要思路 1.dfs本是暴力解决问题的一种方法,数位dp是利用动态规划是思想把以前搜索过的过程记录下来,如果到下一次需要这个结果是就可以直接返回这个值,不需要再从新计算了 2.一般我们是从高位往低位搜索,如果我们需要的结果dp数组里面有我们就不需要从新计算了,如果搜索到了个位就返回一(就是...

changaspl 589

DP - 数位DP - SCOI 2009 - Windy数 + HDU 2089 - 不要62

DP - 数位DP - SCOI 2009 - Windy数 + HDU 2089 - 不要62 文章目录DP - 数位DP - SCOI 2009 - Windy数 + HDU 2089 - 不要621、SCOI 2009 - Windy数2、HDU 2089 - 不要62 1、SCOI 2009 - Windy数 Windy 定义了一种 Windy 数:不含前导零且相邻两个数字之差至少为 2...

njuptACMcxk的博客 250

HDU2089不要62

题目链接:HDU2089不要62 这道题目没有做出来,看来题刷的还不够。问题大致意思是:给出整数区间,求出在区间中的数不含4和62的个数。 一开始我觉得这道题目挺简单的,一来就暴力求解,结果超时,实在不知道怎么改,后来参考了大佬的初学数位DP–hdu 2089才对数位dp有所了解。 下面我们以[ 0 , 3548 ]这个区间来了解数位dp 这与数位区间有关,不能暴力求解,必须在数位上进行递推操作等。 要知道:两个数在进行比较时,我们是从两个数的高位到低位的顺序(如果顺序相反则不行)依次进行比较,当一个数a的

HXZ_CREATE的博客 424

HDU 2089 不要62(数位dp)

目录问题分析状态转移从低位到高位从高位到低位状态设计位最大值代码 问题 HDU 2089 不要62(数位dp) - https://acm.hdu.edu.cn/showproblem.php?pid=2089 分析 状态转移 从低位到高位 注意:图中的最高位是指当前已构造部分的最高位,并非指最终的最高位 #mermaid-svg-gT0VoKIyjP1R8RuS .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--me

jpphy0的博客 209

HDU 2089 不要62

HDU 2089 不要62 题目链接 题目大意: 给定一个区间,求区间有多少个数满足下列条件: 数字没有出现连续的 62 数字中没有出现 4 有多组测试数据 思路: 直接暴力模拟是超时,因为有多组。 这题也是数位dp的一道简单题, 所以可以直接数位dp做 代码: #include <bits/stdc++.h> using namespace std; #define me(a, b) memset(a, b, sizeof(a)) #define IOS() ios::sync_with_

想学开哥的博客 203

数位DP——HDU2089 不要62

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2089 题目大意: 给定一个闭区间n-m,求取该区间中吉利数字的个数。吉利数字的定义为:不包含连续的数字62和数字4。(n,m 解题思路1: 由于m和n是小于100万的所以可以采用暴力打表的做法。 解题思路2: 典型的数位DP。 dp[i][0] 表示i位数

sanmingzi3344的专栏 1016

POJ3253 Round Numbers + HDU2089 不要62 —— 数位DP

POJ3253 :http://poj.org/problem?id=3252 HDU2089:http://acm.hdu.edu.cn/showproblem.php?pid=2089 数位DP: 题目的一般形式为:求 [ L, R ] 范围内满足限制条件的值的个数。 而 [ L, R ]  = [ 0 , R ] - [ 0, L-1 ] ,所以做法就是分别求出 在R

A man can be destroyed, but not defeated. 610

杭电不要62java,【Hdu2089】不要62(数位DP)

Description题目大意:给定区间[n,m],求在n到m中没有“62“或“4“的数的个数。如62315包含62,88914包含4,这两个数都是不合法的。0Solution数位DP,首先预处理数组\(F[i][j]\),表示位数为\(i\),开头为\(j\)时,满足条件的数的个数对于区间\([l,r]\)转化为求\([0,r]-[0,l)\)即可对于区间\([0,n]\)将n按位数存储分别计算...

weixin_33506900的博客 542

数位dp 之 不要62(数位dp入门题)

数位dp 之 不要62(数位dp入门题) HDU-2089 不要62 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。 你的

kitalekita的博客 744
上一篇: ZOJ 3762 Pan's Labyrinth (点集中的最大点-线距&技巧性枚举)
下一篇: Codeforces Round #235 (Div. 2) / 410D Roman and Numbers (带有整除性质的数位DP)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值