当前位置:网站首页>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))。
边栏推荐
猜你喜欢
随机推荐
这几个常用 alias,带你高效做事(下)
【进阶自动化测试】一文1000教你如何用Postman做接口自动化测试
CAS:1620523-64-9_Azide-SS-biotin_生物素-二硫-叠氮
跨端开发技术储备记录
模板字符串
关于GPIO你真的懂了吗?这篇文章都给你整理好了
HCIP第十六天
Cross-end development technical reserve record
ES、Kibana 8.0安装
Engineering Effectiveness Governance for Agile Delivery
IO thread process -> thread synchronization mutual exclusion mechanism -> day6
Use setTimeout to realize setInterval
Data_web(八)mysql增量同步到mongodb
【kali-漏洞扫描】(2.1)Nessus解除IP限制、扫描快无结果、插件plugins被删除(中)
How to deal with commas in the content of the CSV file of the system operation and maintenance series
小朋友学C语言(1):Hello World
False label aggregation
ValidationError: Progress Plugin Invalid Options
Linux操作Jmeter(附带:关于连接上redis无法进行写入操作的问题),JMeter配置多用户进行压力测试
4. Modular programming









