当前位置:网站首页>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))。
边栏推荐
猜你喜欢
随机推荐
C. Keshi Is Throwing a Party- Codeforces Global Round 17
STP生成树
XSS线上靶场---Warmups
ValidationError: Progress Plugin Invalid Options
安全基础8 ---XSS
主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
什么密码,永远无法被黑客攻破?
解决npm -v查看npm版本出现npm WARN config global `--global`, `--local` are deprecated. Use `--location报错
CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide
DO280管理和监控OpenShift平台--资源限制
Cross-end development technical reserve record
函数,递归以及dom简单操作
CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
4. Modular programming
易基因|RNA m5C甲基化测序(RNA-BS)技术介绍
一体化HTAP数据库如此难,为什么他们还要做?
What is the role and difference between buildscript and allprojects?
382. Linked List Random Node
Linux操作Jmeter(附带:关于连接上redis无法进行写入操作的问题),JMeter配置多用户进行压力测试