学习日记--leecode 233

给定一个整数n,计算所有小于等于n的非负整数中数字1出现的个数 ‘’’ 给定一个整数n,计算所有小于等于n的非负整数中数字1出现的个数 例如:n=13,输出6;n=0,输出0 ‘’’ def calTime(n): # 定义一个列表用于存放小于等于n的所有整数 lst = [] if n == 0: return 0 for i in range(1,n+1): lst.append(str(i)) # 遍历列表,计算每个整数中1出现的个数 count = 0 for i in . 阅读详情

题干:

给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。

原理:

个位出现1的规律:每增加10个数,产生一个1,总数=n/10+1+修正值

十位出现1的规律:每增加100个数,产生10个1,总数=(n/100)*10+10+修正值

百位出现1的规律:每增加1000个数,产生100个1,总数=(n/1000)*100 + 100 + 修正值

其他同理。

修正值:考虑十位时,

例如100<=n<110,(n/100)*10+10=20,实际上只有1*10个另外十个考虑的是110~119,所以修正值为10,

例如110<=n<119,(n/100)*10+10=20,实际上只有1*10个,另外的多出的为119,118....n

如果n>119,那么n/100*10 + 10 = 20,110,111,...,119被计算在内是合理的。

所以当末位数为0时,修正值为0,当末位数为2-9时,修正值为i,当末位数为1时,修正值为修正值是(n % i) +1.

//为什么修正值为那么多还有点不太会

源码:

        

int countDigitOne(int n){

    int num = n;

    long i = 1;

    int s = 0;

    while(num>0){

        if(num % 10 == 0)                //末尾为0时

            s += (num / 10) * i ;                                     //修正值为0

        if(num % 10 == 1)                //末尾为1时

            s += (num / 10) * i + (n % i) + 1;                  //修正值为(n % i)

        if(num % 10 > 1)                //末为是1~9时

            s += (num / 10)* i + i;

        

        num = num / 10;//往后移动一位

        i = i*10; 

                }

    return s;

}

参考材料链接:https://leetcode-cn.com/problems/number-of-digit-one/solution/shu-xue-fen-xi-ni-ming-bai-liao-yao-by-62e64arp6t/

Chromatix 7实战:从零开始调优ISP模块的完整流程(附常见报错解决方案) 本文提供了高通平台Camera调试工具Chromatix 7的完整实战指南。详细阐述了从环境准备、项目初始化、基础校正(如LSC、BPC)到核心ISP管线(Demosaic、CCM、HDR)及后处理(CAC、ANR)的调优全流程,并附带了常见报错(如“未初始化实例”)的解决方案,旨在帮助工程师建立系统性的调试方法论。 阅读详情

相关推荐

STM32项目分享:智能家居语音系统

(资料分享见文末)基于STM32的智能家居语音系统温湿度采集:系统通过DHT11模块采集温湿度烟雾监测:通过MQ-2模块采集环境中烟雾浓度光照强度采集:通过BH1750传感器采集环境光照强度窗帘控制:通过步进电机转动模拟窗帘控制风扇控制:通过继电器和指示灯模拟风扇驱动照明控制:通过继电器和指示灯模拟照明驱动蜂鸣器报警:环境烟雾异常情况下蜂鸣器报警OLED显示:显示温湿度、光照强度和烟雾浓度APP功能:使用机智云APP,包括功能有控制照明灯和风扇开关、显示当前温湿度信息。

qq_44016222的博客 4146

leetcode 233.数字1的个数

原题内容如下: 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例: 输入: 13 输出: 6 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/number-of-digit-one 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ——————————————分割线-———————————————— 我的题解 分析 这个题的

zhuruihe2014的博客 1109

Cadence Allegro新手避坑:从原理图到PCB,解决‘netrev.lst does not exist’的完整流程

本文详细介绍了Cadence Allegro从原理图设计到PCB导入网表的完整流程,特别针对新手常见的'netrev.lst does not exist'错误提供了系统解决方案。内容包括环境准备、原理图设计规范、网表生成与导入技巧,以及设计数据管理最佳实践,帮助工程师高效完成PCB设计任务。

weixin_42685438的博客 486

leetcode 233 数字1的个数

1. 题目 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例 1: 输入:n = 13 输出:6 示例 2: 输入:n = 0 输出:0 提示: 0 <= n <=10910^9109 2. 分析 看nnn的范围,力扣的数字上限是2×1092\times 10^92×109,所以时间复杂度必须是O(n)O(n)O(n),这意味着必须一遍遍历完成所有的计算,或者找出与nnn相关的公式,只计算一次。当前,力扣的经典思路为公式法: 所有≤n\leq n≤

古承风的博客 502

【自用】吉林大学计算机系统结构第二章:缓存优化 曲冠南老师版 笔记

容量8KB,2的十三次方,块大小16B,一块用掉四位,剩余2的九次方是标志位,则有512行,每个元素8B,则一块两个元素,a数组150块,b数组152块,不出现容量失效。不管是否交换内容,在同一“伪相联”组中的两块都是用同一个索引得到的,因此失效率相同,即:失效率伪相联=失效率2路。伪相联cache的命中时间等于直接映象cache的命中时间加上伪相联查找过程中的命中时间*该命中所需的额外开销。(6) 由编译器控制的预取,硬件预取的替代方法,在编译时加入预取的指令,在数据被用到之前发出预取请求。

weixin_73587775的博客 1615

如何用Deep OC-SORT提升多目标跟踪精度?实战配置与性能优化指南

本文是一份针对开发者的Deep OC-SORT多目标跟踪实战指南。详细解析了如何通过部署其核心的“动态外观记忆”与“相机防抖”模块来有效应对遮挡与抖动,从而显著提升跟踪精度与连续性。内容涵盖从环境搭建、参数调优到性能压榨的全流程,并提供针对不同场景的配置建议与工程落地技巧。

f9g0h的博客 670

每日算法系列【LeetCode 233】数字 1 的个数

题目描述 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例1 输入: 13 输出: 6 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。 题解 这题是我搜数...

算法码上来 1410

保姆级教程:用HFSS 2023 R2搞定GPS右旋圆极化微带天线(从建模到优化全流程)

本文提供了一份详细的HFSS 2023 R2教程,指导读者从零开始设计GPS右旋圆极化微带天线。涵盖建模、仿真和优化全流程,特别关注圆极化特性的实现与优化,帮助工程师快速掌握天线设计的关键技术。

weixin_42557830的博客 169

统计1的个数

leetcode第233题: 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 解法1:暴力 题目中让计算所有小于n的非负整数的出现数字1的个数,那就将每个数字中1的个数都统计数来,然后相加,就得出了所有1的个数。这样思路很简单,代码更简单。下面是实现: int countDigitOne(int n) { int count = 0; for (int i...

孔晨瑞的博客 4674

Nmap源码分析(端口扫描)

端口扫描是Nmap的核心功能,用于确定目标机的端口状态(开放、关闭、过滤等),也为Nmap的服务与版本扫描、OS扫描、脚本扫描提供基本的指引信息。所以,深入理解端口扫描的实现对分析其他的扫描方式很有帮助。 1简单回顾   首先简要回顾一下端口扫描的原理以及命令行选项。 1.1扫描原理   Nmap提供的10多种类型的端口扫描方法,如TCP SYN/ACK/FIN/Xmas/NULL/ Windows/Connect,FTP Bounce, Idle scan, UDP port u...

墨痕诉清风的博客 1597

MICCAI‘23 | TSegFormer:基于几何引导Transformer的口内扫描3D牙齿分割

光学口内扫描仪(IOS)在数字牙科中广泛应用于提供牙冠和牙龈的详细3D信息。准确的3D牙齿分割对于各种牙科应用至关重要,但现有方法在复杂边界处容易出错,并且在不同患者之间表现不佳。本文提出了TSegFormer,它通过多任务3D Transformer架构捕捉IOS点云中不同牙齿和牙龈之间的局部和全局依赖关系。此外,作者设计了一种基于新颖点曲率的几何引导损失,以端到端方式优化边界,避免了耗时的后处理,从而实现临床适用的分割。

小白学视觉 290

学习日记

看书计划:每月一本c++算法方向的书,一本python ML方向的书 O(∩_∩)O~~ 2019-07月 ★★★★★ 《cs231n》~() ★★★★★ 《算法竞赛进阶指南》~() ★★★☆ ☆ 《算法之美》~() ★★★☆ ☆ 《deeplearning深度学习笔记v5.1》~() 2019-06月 ★★★★★ 《算法竞赛进阶指南》~() ★★★★★ 《LeetCode提高班——第1期》~(2...

WMXNLFD的博客 359

VB摄像头监控

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

2020.07 学习日记

废话 寒假到现在,在家里玩了5个月,来学校又玩了大半个月。以为会做点东西了就什么都懂了,竟然没做准备就投了字节秋招提前批。结果被挂了之后,又被捞起来面试。可以说十分幸运了,但机会都是留给有准备的人的。 2020.07.02 15:00 字节跳动提前批一面,经过这次面试,让我深刻意识到了自己存在的问题(哪都是问题)。 做了两年切图仔,只会用(连用的不会)。基础性、原理性知识完全没有掌握。平时遇到问题都是搜一下,然后跟着解决,也从不会太深入了解。 现在十分后悔。 计划 一个月内不再投简历,专心巩固基础知识 书

Gem 634

深度学习工具包 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")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

学习日记【LeetCode】234. 回文链表

【LeetCode】234. 回文链表 一、题目内容 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 二、考查内容 双指针、递归、栈、链表反向、快慢针 三、解题思路 思路一:将链表复制到一个数组中,然后用双指针判断这是不是回文(稍微改一下就是:将链表压入栈,然后栈顶元素和链表逐一比较) 思路二:利用计算机在执行函数递归的时候其实是在使用栈的特点,使用递归来进行链表的反向遍历。虽然这种方法对于

weixin_45921043的博客 156

【LeetCode刷题日记】17.电话号码的字母组合

本文介绍了LeetCode第17题"电话号码的字母组合"的解题思路。题目要求根据数字字符串返回所有可能的字母组合,采用回溯算法解决多层循环问题。通过建立数字到字母的映射关系,使用StringBuilder高效构建组合字符串,并详细分析了回溯过程。代码实现了异常处理(空输入和非法字符),通过递归遍历所有可能的组合情况,最终将结果存入列表返回。时间复杂度为O(3^N ×4^M),其中N和M分别对应3字母和4字母的数字个数。

任岁月风干理想再也找不回真的我 2067

给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。

class Solution { public int countDigitOne(int n) { if(n&lt;1) return 0; int count = 0; int base = 1; int round = n; while(round&gt;0){ int weight = round%1...

shengqiheng的博客 4559

233. 数字 1 的个数:给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。

题目:给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 1、暴力求解法: class Solution { public: int countDigitOne(int n) { int res=0; for(int i=1;i<=n;i++){ string str=to_string(i); res+=count(str.begin(),str.end(),'1');

yuzou____5000的博客 2660

力扣每日一题2021.08.13数字1的个数

文章目录题目描述示例1示例2提示思路:递归递归 题目描述 给定一个整数n,计算所有小于等于n的非负整数中数字1出现的个数。 示例1 输入:n = 13 输出:6 示例2 输入:n = 0 输出:0 提示 0 <= n <= 2*109 思路:递归 递归 依据题意,需要统计[0, n]范围内所有整数中,数字1出现的个数。 先对数字观察规律如下: 9以下的1有1个。 99以下的1有20个,其中既包含了尾数为1的9个两位数,又包括以1开头的10个两位数,还有1这个数,总共有20个1。 9

wcy1034036507的博客 537

233 数字1的个数(组合数)

1. 问题描述: 给定一个整数 n,计算所有小于等于n的非负整数中数字1出现的个数。 示例 1: 输入:n = 13 输出:6 示例 2: 输入:n = 0 输出:0 提示: 0 <= n <= 2 * 10 ^ 9 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/number-of-digit-one 2. 思路分析: 这道题目其实是一个组合数的问题,我们需要计算0~n中数字中的所有1的数目,其实我们可以考虑当前数字n的

二哈 623

LeetCode 233. 数字1的个数

题目描述 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例: 输入: 13 输出: 6 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。 问题分析 假设我们要计算一个六位数abcdef有多少个1,那么我们要计算6个位置分别出现了多少次1,最后把6个位置的结果加和就是答案了。假如当前正在计算位置 c 出现了多少个1:_ _ ...

yj_coder的博客 373

LeetCode233. 数字 1 的个数(C++)&剑指43.1~n整数中1出现的个数详解

原题如下: 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例: 输入: 13 输出: 6 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。 解法1 剑指offer中给出复杂度为O(logn)的解法思路为 例如:给定21345,将其分成两部分1-1345与1346-21345; 其中1346-21345部分的1的个数=最高位中1的个数+...

Isabella327的博客 915

剑指Offer 43.1~n整数中1出现的次数 | LeetCode 233.数字1的个数 (Python)

题目介绍 给定一个整数n,计算所有小于等于n的非负整数中数字1出现的个数。 输入: 13 输出: 3 解释: 数字1出现在以下数字中:1,10,11,12,13

ChungChinKei' blog 1125

计算n以内中的所有数字包含1的个数

题意:给定一个十进制正整数n,写下从1开始到n的所有整数,出现“1”的所有个数。第一种方法是从1到n循环,时间复杂度过高:public static int count1(int n) { int result=0; for(int i=1;i&lt;=n;i++) { int j=i; while(j!=0) { result+=(j%10==1?1:0); j/=10;...

zfgogo的博客 3121

LeetCode解题笔记 38 —— 233.数字 1 的个数

题目 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例: 输入: 13 输出: 6 解释: 数字 1 出现在以下数字中: 1, 10, 11, 12, 13 。 解法 class Solution { //以下注释以n=5683为例 public int countDigitOne(int n) { if(n&l...

JohnLiu的博客 579

给定一个正整数n,找到小于或等于n的非负整数,其二进制表示不包含连续的整数。

本题源自leetcode  600 https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/discuss/ =---------------------------------------------------------------------- 思路: 动态规划  用斐波那契数列

i_am_bird的博客 2981

计算数字 1 的个数(小于等于 n 的非负整数中数字 1 出现的个数)

这个问题乍一看,我最开始以为是计算二进制位的1的个数(最近对二进制比较敏感,想啥问题都是先想着能不能二进制解决)。然后仔细看了问题之后才发现,其实就是计算十进制中1的个数。其实理解问题之后,感觉也不是很难,一个暴力计算就搞定,不过,光用暴力解决问题并不是我的风格,所以还要想着其他更有效的方式。这里记录这个问题,不是因为他有多难,而是这个问题其实是一个纯粹的数学问题,我们需要进行数学分析就可以很简单的实现出来并解决,而不是使用语言上的奇淫巧技。

BoCong-Deng的博客 3309
上一篇: 数据结构第五章——树与二叉树(概念与定义)
下一篇: 学习日记--leecode 20
Allen_Ming
博客等级 码龄6年 1粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值