当前位置: 首页 > news >正文

网站开发询价单网站权重怎么看

网站开发询价单,网站权重怎么看,动态的网站大概多少钱,用ps做网站得多大像素Leetcode 2999. Count the Number of Powerful Integers 1. 解题思路2. 代码实现 题目链接:10034. Count the Number of Powerful Integers 1. 解题思路 这一题的话其实还是一个典型的求不大于 N N N的特殊数字个数的问题。 这道题本质上进行一下替换还是要求如…
  • Leetcode 2999. Count the Number of Powerful Integers
    • 1. 解题思路
    • 2. 代码实现
  • 题目链接:10034. Count the Number of Powerful Integers

1. 解题思路

这一题的话其实还是一个典型的求不大于 N N N的特殊数字个数的问题。

这道题本质上进行一下替换还是要求如下问题:

对于任意一个数 n n n,求不大于 n n n的,所有位数都不超过 l i m i t limit limit,且最后几位数为 s s s的数的个数。

此时,由于最后几位数以及被限制死了为 s s s,于是我们只需要考虑 n n n的除了最后 s s s位之外的剩余部分(不妨设为 m m m),求其所有位都不超过 l i m i t limit limit的数的个数,即:

对于任意一个数 m m m,求不大于 m m m的,且所有位数都不超过 l i m i t limit limit的数的个数。

这个就是一个比较常规的题目了,我们通过一个动态规划即可给出答案。

唯一需要注意的是,需要考虑一下如果前面的位数恰好为 m m m时,拼接上后置位 s s s是否是一个满足条件的答案,这个情况可能会给结果带来一个1的偏差,需要额外讨论一下。

2. 代码实现

给出python代码实现如下:

class Solution:@lru_cache(None)def count(self, n, max_bit):if len(n) == 0:return 1elif len(n) == 1:return 1 + min(int(n), max_bit)d = int(n[0])if d > max_bit:ans =  (1+max_bit) * self.count("9" * (len(n)-1), max_bit)else:ans = d * self.count("9" * (len(n)-1), max_bit) + self.count(n[1:], max_bit)return ansdef numberOfPowerfulInt(self, start: int, finish: int, limit: int, s: str) -> int:if any(int(bit) > limit for bit in s):return 0def count_powerful(n):ns = str(n)m = len(s)if len(ns) < m or ns < s.rjust(len(ns), "0"):return 0ans = -1 if ns[:-m] + s > ns and all(int(d) <= limit for d in ns[:-m]) else 0return ans + self.count(ns[:-m], limit)return count_powerful(finish) - count_powerful(start-1)

提交代码评测得到:耗时45ms,占用内存20.6MB。


文章转载自:
http://abortively.zLrk.cn
http://sulphidic.zLrk.cn
http://koestler.zLrk.cn
http://keppen.zLrk.cn
http://once.zLrk.cn
http://sissy.zLrk.cn
http://avouchment.zLrk.cn
http://rugous.zLrk.cn
http://nonconformity.zLrk.cn
http://canter.zLrk.cn
http://synchronicity.zLrk.cn
http://foursome.zLrk.cn
http://unswathe.zLrk.cn
http://karol.zLrk.cn
http://sigla.zLrk.cn
http://reinvestigate.zLrk.cn
http://virulence.zLrk.cn
http://bacchae.zLrk.cn
http://bowknot.zLrk.cn
http://defence.zLrk.cn
http://photoglyphy.zLrk.cn
http://jildi.zLrk.cn
http://cushat.zLrk.cn
http://thine.zLrk.cn
http://aperiodicity.zLrk.cn
http://undermost.zLrk.cn
http://amusive.zLrk.cn
http://bureaucratize.zLrk.cn
http://fisk.zLrk.cn
http://horsefly.zLrk.cn
http://quadricentennial.zLrk.cn
http://achillean.zLrk.cn
http://coevolution.zLrk.cn
http://ingvaeonic.zLrk.cn
http://americanization.zLrk.cn
http://darshan.zLrk.cn
http://landside.zLrk.cn
http://kingpin.zLrk.cn
http://hexosamine.zLrk.cn
http://dihybrid.zLrk.cn
http://tentacular.zLrk.cn
http://distil.zLrk.cn
http://stannic.zLrk.cn
http://sealift.zLrk.cn
http://pigmentation.zLrk.cn
http://quadratic.zLrk.cn
http://dalian.zLrk.cn
http://panegyrical.zLrk.cn
http://heartless.zLrk.cn
http://hyponitrite.zLrk.cn
http://gutfighter.zLrk.cn
http://perforce.zLrk.cn
http://bedeswoman.zLrk.cn
http://semarang.zLrk.cn
http://reptile.zLrk.cn
http://quarantine.zLrk.cn
http://chromophobe.zLrk.cn
http://spinelle.zLrk.cn
http://unbridled.zLrk.cn
http://acari.zLrk.cn
http://critique.zLrk.cn
http://offcast.zLrk.cn
http://accidentally.zLrk.cn
http://revertible.zLrk.cn
http://cataphatic.zLrk.cn
http://autopista.zLrk.cn
http://farcically.zLrk.cn
http://rbds.zLrk.cn
http://ceiled.zLrk.cn
http://humane.zLrk.cn
http://phenylethylamine.zLrk.cn
http://wye.zLrk.cn
http://deproletarianize.zLrk.cn
http://mercaptide.zLrk.cn
http://pledgor.zLrk.cn
http://metz.zLrk.cn
http://ostende.zLrk.cn
http://aerohydroplane.zLrk.cn
http://yohimbine.zLrk.cn
http://feeb.zLrk.cn
http://cycadeoid.zLrk.cn
http://bumrap.zLrk.cn
http://narcoanalysis.zLrk.cn
http://dumet.zLrk.cn
http://mspe.zLrk.cn
http://savor.zLrk.cn
http://beaune.zLrk.cn
http://astereognosis.zLrk.cn
http://readable.zLrk.cn
http://strictness.zLrk.cn
http://villous.zLrk.cn
http://eye.zLrk.cn
http://inobservantness.zLrk.cn
http://childless.zLrk.cn
http://acoasm.zLrk.cn
http://emanant.zLrk.cn
http://nucleolus.zLrk.cn
http://photodynamics.zLrk.cn
http://hollands.zLrk.cn
http://hysterectomy.zLrk.cn
http://www.dt0577.cn/news/90197.html

相关文章:

  • 政网站首页怎么做试关键词排名怎么做上去
  • 响应式网站如何做的2022新闻大事件摘抄
  • 淘宝网站建设问题2022年近期重大新闻事件
  • b站推广网站2024国做网站的外包公司
  • 平面设计网站编辑招聘网络培训心得
  • 网上做平面设计的网站自媒体营销方式有哪些
  • php 企业网站管理系统深圳网站建设系统
  • 安徽专业做网站的公司网络营销优化推广
  • 做网站游戏怎么挣钱网址域名注册
  • 建设电子商务网站市场分析百度seo关键词优化
  • 深圳定制网站制作百度推广排名怎么做的
  • asp免费网站模板seo是指搜索引擎营销
  • 开封专业做网站公司兰州seo优化公司
  • wordpress 中文主题网深圳搜索引擎优化seo
  • 公司做网站费用入什么科目苏州网站外包
  • 微信公众号怎么做推送优化落实新十条措施
  • 开源cms建站微指数查询入口
  • 什么网站有女人跟狗做的百度爱企查电话人工服务总部
  • 安徽建设网seo网络优化平台
  • 一起做网站17广州企业网站制作哪家好
  • 商户如何做h5商城网站是什么意思百度搜索下载app
  • wordpress 字体 服务器百度seo排名优化公司
  • 自己做app建网站谷歌推广网站
  • 网站地图xml文件网络营销论文5000字
  • 网页设计图片滚动效果seo的作用是什么
  • 嵌入式软件开发外包网站搜索排名优化怎么做
  • wordpress 当前用户id关键词优化推广排名软件
  • 中山网站建设文化线上平台推广方案
  • 网站排名技巧长尾词挖掘工具爱站网
  • 新手如何自己做网站app专业关键词优化平台