当前位置:网站首页>1837. Sum of digits under k-ary representation
1837. Sum of digits under k-ary representation
2022-07-26 10:59:00 【Lovey_ Beihe】
Give you an integer n(10 Base number ) And a cardinality k , Would you please n from 10 The hexadecimal representation is converted to k Hexadecimal said , Calculate and return the... Of each number after conversion The sum of the .
After the transformation , Your numbers should be taken as 10 Hexadecimal Numbers , And the sum of them should be 10 Hexadecimal means to return .
public static int SumBase(int n, int k)
{
int count = 0;
int res;
while (n / k != 0)
{
res = n % k;
count += res;
n /= k;
}
res = n % k;
count += res;
return count;
}
边栏推荐
- Sword finger offer (twenty): stack containing min function
- Pytest fixture decorator
- 菜鸟看源码之SparseArray
- Pengge C language lesson 4 (3)
- Sword finger offer (8): jump the steps
- Pengge C language - minesweeping 2021-08-16
- Sword finger offer (49): convert a string to an integer
- Drbl diskless startup + Clonezilla network backup and restore system
- Sword finger offer (43): left rotation string
- @Notblank, @notnull, @notempty differences and uses
猜你喜欢

@Notblank, @notnull, @notempty differences and uses

pytest fixture装饰器

Bash shell learning notes (4)

RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)

nmap弱点扫描结果可视化转换

LE Audio规范概述

用两个栈实现队列

Bash shell learning notes (III)

Capture ZABBIX performance monitoring chart with selenium

Software Testing Overview: the background, essence and process of software testing
随机推荐
MySQL learning notes
C language pengge 20210812c language function
Wireshark basic tutorial Ethernet frame analysis.
Sword finger offer (twenty): stack containing min function
349. 两个数组的交集
雨课堂 《知识产权法》笔记
Pengge C language 20210811 program structure operation
Sword finger offer (V): queue with two stacks
看源码之LinkedList
Bash shell learning notes (V)
ThreadPoolExecutor是怎样执行任务的
Kali view IP address
企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
Summary of the seventh class of pengge C language
MFC picture control
Pengge C language lesson 4 (3)
pytest conftest.py和fixture的配合使用
Definition and use of C language namespace
mother
菜鸟看源码之ArrayList