当前位置:网站首页>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;}};
边栏推荐
- php根据两点经纬度计算距离
- alicloud3搭建wordpress
- In-depth understanding of JVM-memory structure
- Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
- 倒计时2天,“文化数字化战略新型基础设施暨文化艺术链生态建设发布会”启幕在即
- 高效目标检测:动态候选较大程度提升检测精度(附论文下载)
- Anaconda 虚拟环境迁移
- async 和 await 原来这么简单
- C51 存储类型与存储模式
- Use ControlTemplate or Style from resource file in WPF .cs and find the control
猜你喜欢
百利药业IPO过会:扣非后年亏1.5亿 奥博资本是股东
(十六)51单片机——红外遥控
【飞控开发高级教程4】疯壳·开源编队无人机-360 度翻滚
Anaconda virtual environment migration
从文本匹配到语义相关——新闻相似度计算的一般思路
tRNA修饰2-甲基胞嘧啶(m2C)|tRNA修饰m2G (N2-methylguanosine)
ESP8266-Arduino编程实例-WS2812驱动
- [email protected] 594/[email prote"/>
RNA核糖核酸修饰Alexa 568/[email protected] 594/[email prote
机器学习中专业术语的个人理解与总结(纯小白)
高并发,你真的理解透彻了吗?
随机推荐
Line the last time the JVM FullGC make didn't sleep all night, collapse
【leetcode】剑指 Offer II 008. 和大于等于 target 的最短子数组(滑动窗口,双指针)
leetcode 268. 丢失的数字(异或!!)
Detailed AST abstract syntax tree
LeetCode 622. 设计循环队列
Detailed demonstration pytorch framework implementations old photo repair (GPU)
嵌入式分享合集27
node版本切换工具NVM以及npm源管理器nrm
149. 直线上最多的点数-并查集做法
EMQX Newsletter 2022-07|EMQX 5.0 正式发布、EMQX Cloud 新增 2 个数据库集成
Anaconda virtual environment migration
Anaconda 虚拟环境迁移
开源教育论坛| ChinaOSC
net-snmp私有mib动态加载到snmpd
揭秘5名运维如何轻松管理数亿级流量系统
2022.8.2
小马智行起诉擎天智卡:索赔6000万 彭军称要斗争到底
Alexa染料标记RNA核糖核酸|RNA-Alexa 514|RNA-Alexa 488|RNA-Alexa 430
tRNA修饰2-甲基胞嘧啶(m2C)|tRNA修饰m2G (N2-methylguanosine)
子结点的数量(2)