当前位置:网站首页>leetcode 1837. The sum of the digits in the K-base representation
leetcode 1837. The sum of the digits in the K-base representation
2022-08-03 20:10:00 【Luna who can program】
Given an integer n (base 10) and a base k , please convert n from base 10 to base k, calculate and return the sum of the converted digits.
After conversion, the individual digits should be treated as decimal digits, and their sum should also be returned in decimal notation.
Example 1:
Input: n = 34, k = 6
Output: 9
Explanation: 34 (decimal) is represented as 54 in hexadecimal.5 + 4 = 9 .
Example 2:
Input: n = 10, k = 10
Output: 1
Explanation: n itself is base 10.1 + 0 = 1 .
Tip:
1 <= n <= 100
2 <= k <= 10
class Solution {public:int sumBase(int n, int k){int he=0;while(n){he+=(n%k);n/=k;}return he;}};边栏推荐
- Edge box + time series database, technology selection behind Midea's digital platform iBuilding
- Alexa染料标记RNA核糖核酸|RNA-Alexa 514|RNA-Alexa 488|RNA-Alexa 430
- Internet Download Manager简介及下载安装包,IDM序列号注册问题解决方法
- The sword refers to Offer II 044. The maximum value of each level of the binary tree-dfs method
- Detailed explanation of JWT
- JMeter笔记5 |Badboy使用和录制
- Statistical machine learning 】 【 linear regression model
- 刷题错题录1-隐式转换与精度丢失
- php根据两点经纬度计算距离
- 子树的大小
猜你喜欢
随机推荐
基础软件与开发语言开源论坛| ChinaOSC
多模态 参考资料汇总
【飞控开发高级教程3】疯壳·开源编队无人机-定高、定点、悬停
【飞控开发高级教程6】疯壳·开源编队无人机-AI语音控制
软件测试基本流程有哪些?权威的第三方软件检测机构推荐
力扣206-反转链表——链表
边缘盒子+时序数据库,美的数字化平台 iBuilding 背后的技术选型
leetcode 899. 有序队列
leetcode 1837. K 进制表示下的各位数字总和
刷题错题录1-隐式转换与精度丢失
Mapper输出数据中文乱码
Anaconda 虚拟环境迁移
花 30 美金请 AI 画家弄了个 logo,网友:画得非常好,下次别画了!
RNA-ATTO 390|RNA-ATTO 425|RNA-ATTO 465|RNA-ATTO 488|RNA-ATTO 495|RNA-ATTO 520近红外荧光染料标记核糖核酸RNA
JMeter笔记5 |Badboy使用和录制
ES6-箭头函数
MapReduce介绍及执行过程
头条服务端一面经典10道面试题解析
力扣203-移除链表元素——链表
Anaconda virtual environment migration









