> 文章列表 > 第十四届蓝桥杯PythonB组

第十四届蓝桥杯PythonB组

第十四届蓝桥杯PythonB组

文章目录


前言

😎🥳😎🤠😮🤖🙈💭🍳🍱
答案未证实,仅供参考


主要内容

🦞🦐🦀🦑🦪

2023

第十四届蓝桥杯PythonB组

有多少个完全包含2023

从末尾开始一个一个比对,对比上则指针后移,全部比对上flag值为4
西巴,完全不包含,我算的完全包含,坤!

def isTrue(x):flag =0while x:if flag==4:return Truetmp=x%10x=int(x/10)if tmp==st[flag]:flag+=1else:continueif flag==4:return Truereturn False
ans=0
st=[3,2,0,2]
print(isTrue(2022352))
for i in range(12345678,98765432+1):if isTrue(i):ans+=1
print(ans)
#460725

第十四届蓝桥杯PythonB组

第十四届蓝桥杯PythonB组

子序列的价值

用的贪心,每次取最大
肯定是不对的,比如说xyx
应该用dp

s=input()
# s='azaz'
s=[ord(i)-96 for i in s]
ans=0
while sum(s)!=-1*len(s):m=max(s)ans+=mindex=s.index(m)s[index]=-1if index-1>=0:s[index-1]=-1if index+1<len(s):s[index+1]=-1
print(ans)

第十四届蓝桥杯PythonB组

第十四届蓝桥杯PythonB组


总结

🐋 🐬 🐶 🐳 🐰 🦀☝️ ⭐ 👉 👀

如果你对这篇文章感兴趣,欢迎在评论区留言,分享你的想法和建议。如果你喜欢我的博客,请记得点赞、收藏和关注我,我会持续更新更多有用的网页技巧和教程。谢谢大家!


更多宝藏

🍇🍉🍊🍏🍋🍅🥝🥥🫒🫕🥗
项目仓库看这里🤗:
https://github.com/w-x-x-w
https://gitee.com/w-_-x
博客文章看这里🤭:
https://blog.csdn.net/weixin_62650212
视频推送看这里🤤:
https://space.bilibili.com/1909782963