当前位置:网站首页>483. Smallest Good Base
483. Smallest Good Base
2022-08-03 21:47:00 【51CTO】
For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1.
Now given a string representing n, you should return the smallest good base of n in string format.
Example 1:
Example 2:
Example 3:
Note:
The range of n is [3, 10^18].
The string representing n is always valid and will not have leading zeros.
思路:
首先完成字符串到数字的转换,然后对于特定的num,当前的最长的其他进制的表示长度是进制为2时的表示长度,就是log2(num)+1(注意:10..0有t个0,那么10..0=2^t)。那么指数i的遍历区间就是[1,log2(num)+1]。对于当前数的当前指数i,可能的base整数取值是num^(1/(i-1))。
边栏推荐
猜你喜欢
随机推荐
STP生成树
现网设备兼容SRv6网络演进
Interesting opencv - record image binarization and similarity
YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
XSS线上靶场---prompt
6. XML
研究Fabric中Etcd的Raft应用
idea2021.1.3版本如何启动多个客户端程序
基于DMS的数仓智能运维服务,知多少?
StoneDB 助力 2022 开放原子全球开源峰会
[3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题
超级实用网站+公众号合集
385. Mini Parser
nxp官方uboot移植到野火开发板PRO(修改LCD部分和网络部分)
CAS:1620523-64-9_Azide-SS-biotin_biotin-disulfide-azide
上课笔记(6)(1)——#629. 表达式括号匹配(stack)
Data_web(九)mongodb增量同步到mongodb
安全基础8 ---XSS
小朋友学C语言(1):Hello World
HCIP第十六天









