[LeetCode]258. Add Digits

使用kali对局域网内的主机进行远程控制 输入命令:hydra -l administrator -P/usr/share/woerdlists/rockyou.txt 192.168.100.241 smb -V。账户(adminitrator)密码:123456 【一般账户都是我们知晓了,如果不知道账户进行破解那几乎不太可能,密码如果设置的特别复杂无规律也是特别难破解的】【-r:扫描整个网段 后面就是设置 192.168.241.100/24的网络地址段 为 192.168.241.0/24 0和/24之间不要空格】 阅读详情

[LeetCode]258. Add Digits

题目描述

这里写图片描述

思路

循环相加每一位
每次获取num的个位,加到和中,num = num / 10,循环直至num / 10为0,最后在外层sum += num,
对得到的sum进行判断,若大于等于10,递归处理
否则输出
详见代码

update
没看清题目,不准用递归和循环
实际是一道规律题
对9取模即可

代码

class Solution {
public:
    int addDigits(int num) {
        int sum = 0;

        if (sum == 10) {
            return 1;
        }

        while (num / 10) {
            sum += num % 10;
            num /= 10;
        }
        sum += num;

        if (sum >= 10) {
            sum = addDigits(sum);
        }
        return sum;
    }
};
STM32cubeMX配置FreeRTOS软件定时器 文章目录前言1.软件定时器概述一.软件定时器特性二、使用cubeMX生成软件定时器总结 前言 本文主要带大家了解什么是软件定时器,并且带大家使用cubeMX配置软件定时器。 1.软件定时器概述 一.软件定时器特性 软件定时器就是一个闹钟当时间到了就执行相对应的任务或者代码。软件定时器是基于系统滴答中断的。在FreeRTOS中我们可以设置无数个软件定时器。 指定时间:启动定时器和运行回调函数,两者的间隔被称为定时器的周期 (period)。 指定类型定时器有两种类型: 1.一次性 这类定时器启动后,它的回调函 阅读详情

相关推荐

卫星测试科普(三):卫星载荷的核心测试设备探秘

总的说来,卫星芯片与元器件,部组件与单机,整机与子系统,系统与整星的设计、定型、制造、验证、总装、发射、在轨等环节都离不开各种测试场景,对于这些卫星测试场景而言,“射频三大件”与高速数字示波器是构成强大测试系统的基础。卫星通信信号生成:覆盖Ka、Q等波段,具备扫频、脉冲、数字调制、噪声信号、雷达信号、数据链信号、OFDM 等多种信号库,用于测试和验证卫星电子设备的电气性能、频率响应、抗干扰能力等。卫星的通信需要高效、快速地传输大量数据,高速信号的质量至关重要,如果卫星信号不佳,卫星就会出现故障或者隐患。

spwbjss的博客 2319

leetcode 258. Add Digits

Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only on

Decorator2015的博客 528

华为星闪SLE实战:手把手教你用HarmonyOS开发智能家居控制应用(附完整代码)

本文详细介绍了如何利用华为星闪SLE技术,结合HarmonyOS开发智能家居控制应用。通过对比传统无线技术,阐述了星闪SLE在低时延、高可靠性和高并发方面的优势,并提供了从环境搭建、设备发现、连接管理到核心控制代码的完整实战教程,帮助开发者快速上手这一无线短距通信技术。

bert9linguist的博客 506

leetcode.258.Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

RaymondWong的博客 255

脑电数据预处理十四:主成分分析(PCA)用于伪迹去除与降维

本文探讨了主成分分析(PCA)在脑电图(EEG)预处理中的双重应用。针对EEG数据的高维特性和伪迹干扰问题,PCA既可有效去除高振幅伪迹(如眼动、心电等),又能实现数据降维。文章详细解析了PCA的核心原理,包括正交基向量投影和方差最大保留机制,并提供了基于MNE-Python的完整实现方案。通过代码示例展示了PCA在伪迹去除和降维中的具体应用效果,包括功率谱密度和时域波形的可视化对比。虽然ICA在复杂伪迹处理上更具优势,但PCA以其算法简单、计算高效的特点,成为EEG分析流程中不可或缺的基础工具。

qq_32516809的博客 1417

[特殊字符] 智能补货(AI-driven Replenishment)完整实施方案

补货量=预测需求+安全库存−当前库存补货量 = 预测需求 + 安全库存 - 当前库存补货量=预测需求+安全库存−当前库存。:基于 LSTM/Transformer 预测未来 30/60/90 天的销量。

nbsaas-boot基于Request-Response的企业级快速开发框架 967

LeetCode 258. Add Digits 题解(C++)

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

prayyojay的博客 391

PCB工艺-SI9000使用教程

本文介绍了阻抗计算工具SI9000的使用方法,重点讲解了微带线与带状线的区别、共面阻抗概念及参考面选择。通过USB差分走线实例,详细说明了如何选择计算模型、填写参数并确定线宽线距。文章还提供了层叠设计资料和工厂常规阻抗表格作为参考,建议制板时标注需控阻抗的线路供板厂调整。最后简单提及了嘉立创阻抗计算工具作为备选方案。

weixin_50120208的博客 2026

[leetcode]258. Add Digits

[leetcode]258. Add Digits Analysis 厉害的人总是那么的厉害呀~—— [菜鸡反省中~] Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. 简单题,直接看代码吧。 Implement cl...

weixin_32135877的博客 134

【学习系列】SAP RAP 8:行为定义-Authorization Control

本文介绍了SAP RAP中的授权控制实现方法,主要分为读取操作和修改操作两种场景。读取操作通过ABAP CDS的数据控制语言(DCL)实现,使用访问控制对象限制数据可见范围;修改操作则通过行为定义中的权限检查,包括全局授权、实例授权和预检查三种方式。文章详细说明了如何使用DCL创建访问控制规则,并通过实例演示了全局授权和实例授权的代码实现方法,以及预检查功能在数据更新前的权限验证。这些授权控制机制共同确保用户只能访问和操作其权限范围内的数据,有效保障系统安全性。

DeveloperMrMeng的博客 436

zemax 如何编译用户自定义DLL(含VS下载教程)

zemax 如何编译用户自定义DLL(含VS下载教程)

weixin_72050316的博客 492

LeetCode - 258. Add Digits

链接 258. Add Digits 题意 给定一个非负整数,反复做如下操作:将它的各位数相加得到一个值,若该值位数仍大于1,重复以上操作,直到位数为1。 思路 模拟即可 代码 Java: public int addDigits(int num) { while(num>=10){ num = (num/10)+num%10; } ...

170

npm install failed如何办?

上网搜索,说是网络配置不太对。按照如下几步,保证解决问题。在运行npm install指令时,出现如下错误。

xiezhipu的博客 879

leetcode-258.add digits/Digital root

leetcode-258.Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since

绯浅yousa的笔记 666

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Leetcode 258. Add Digits

转载于:https://www.cnblogs.com/winder-knight/p/9804070.html

weixin_30418341的博客 64

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

[LeetCode 258] Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

coder 进阶的专栏 8844

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

leetcode 258: Add Digits

Add Digits Total Accepted: 5383 Total Submissions: 11876 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 3

西施豆腐渣 7466

LeetCode 258: Add Digits 题解

刚开始以为是一道水题,一下就过了,结果题没看完,要求时间复杂度为O(1)O(1)。LeetCode 258: Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the pr

请叫我AXin 1132

LeetCode 258. Add Digits

258. Add Digits(各位相加) 题目:   给定一个非负整数num,反复将各个位上的数字相加,直到结果为一位数。   示例:   输入: 38   输出: 2   解释: 各位相加的过程为:3 + 8 = 11, 1 + 1 = 2。 由于2 是一位数,所以返回 2。   进阶:  你可以不使用循环或者递归,且在 O(1) 时间复杂度内解决这个问题吗...

weixin_30298497的博客 118

leetcode 258- Add Digits

leetcode题目汇集 — Add Digitsleetcode 258- Add Digits 题目要求 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process

知足常乐,知行合一 367

leetcode 258---Add Digits, 关于C++中负数取余

一切源于leetcode 258---Add Digits这道题,https://leetcode.com/problems/add-digits/ 题目的解法很简单,有两种公式,一种是我这种笨笨的人写的: class Solution { public: int addDigits(int num) { if(num==0) return 0;

ChenLI's blog 846

[LeetCode]258. Add Digits(把数各个位上的数字相加)

258. Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit. 题目大意: 给定一个非负整数num,重复地添加所有其数字,直到结果只有一个数字。For example:Given num = 38, the process is

whl_program的博客 919

【leetcode】258. Add Digits

problem 258. Add Digits solution1: class Solution { public: int addDigits(int num) { int sum = 0; int n = num; while(n/10) { sum = n/10 + n...

weixin_30481087的博客 90

LeetCode258——Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

代码菌的blog 5176

leetcode-258-Add Digits

Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2.

早睡早起好少年 664

LeetCode 258 Add Digits

Problem: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit. For example: Givennum = 38, the process is like:3 + 8 = 11,1 + 1 = 2. Since2h...

dilian4850的博客 159
上一篇: [LeetCode]292. Nim Game
下一篇: [LeetCode]231. Power of Two
charon____
博客等级 码龄11年 3粉丝 202原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值