我是靠谱客的博主 优雅宝贝,最近开发中收集的这篇文章主要介绍第十四届蓝桥杯模拟赛(Python),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

写在前面

  1. 本篇题解涵盖范围为1 - 8 题,最后两题本人没能解出来
  2. 使用语言为Python
  3. 过样例 不确定能否AC
  4. 仅供参考 若有错误 欢迎指出
  5. 最后两题若有佬会 可以评论给出你的思路 感激不尽 ????

 4e36f88729704afbb50fa2848b985168.png

 

# 直接调用转二进制函数即可
# 具体用法请查官方文档

s = 2022
ans = bin(s)
print(len(ans[2:]))

 

 8511f4328807432f8b42c921b8234502.png

调用datetime函数,枚举每一天并判断是否符合要求 

import datetime

start = datetime.date(2022,1,1)
ans = 0 
diff = datetime.timedelta(1)
end = datetime.date(2022,12,31)

def check(date) :
    
    if datetime.date.weekday(date) == 5 or datetime.date.weekday(date) == 6 :
        return True
    date = str(date)
    if date[-2:] == '01' or date[-2:] == '11' or date[-2:] == '21' or date[-2:] == '31' :
        return True
    return False

while start <= end :
    if check(start) : ans += 1
    start += diff
    
print(ans)

 

 4d16851903e54476965b6431b540a334.png

简单模拟,大于12时输出答案 


idx = 1 
target = 12 
tot = 0 
ans = 0

while tot < target :
    tot += 1 / idx 
    ans += 1 
    idx += 1
    
print(ans)

 

dba1e1f50d8f4cd1a57be907e50ac0fd.png 

 遍历每个点,判断是否为山谷即可


s = "PHQGHUMEAYLNLFDXFIRCVSCXGGBWKFNQDUXWFNFOZVSRTKJPREPGGXRPNRVY
STMWCYSYYCQPEVIKEFFMZNIMKKASVWSRENZKYCXFXTLSGYPSFADPOOEFXZBC
OEJUVPVABOYGPOEYLFPBNPLJVRVIPYAMYEHWQNQRQPMXUJJLOOVAOWUXWHMS
NCBXCOKSFZKVATXDKNLYJYHFIXJSWNKKUFNUXXZRZBMNMGQOOKETLYHNKOAU
GZQRCDDIUTEIOJWAYYZPVSCMPSAJLFVGUBFAAOVLZYLNTRKDCPWSRTESJWHD
IZCOBZCNFWLQIJTVDWVXHRCB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AEARWTVJSJBAOIOJ
LWHYPNVRUIHOSWKIFYGTYDHACWYHSGEWZMTGONZLTJHGAUHNIHREQGJFWKJS
MTPJHAEFQZAAULDRCHJCCDYRFVVRIVUYEEGFIVDRCYGURQDREDAKUBNFGUPR
OQYLOBCWQXKZMAUSJGMHCMHGDNMPHNQKAMHURKTRFFACLVGRZKKLDACLLTEO
JOMONXRQYJZGINRNNZWACXXAEDRWUDXZRFUSEWJTBOXVYNFHKSTCENAUMNDD
XFDMVZCAUTDCCKXAAYDZSXTTOBBGQNGVVPJGOJOGLMKXGBFCPYPCKQCHBDDZ
WRXBZMQRLXVOBTWHXGINFGFRCCLMZNMJUGWWBSQFCIHUBSJOLLMSQSGHMCPH
ELSOTFLBGSFNPCUZSRUPCHYNVZHCPQUGRIWNIQXDFJPWPXFBLKPNPEELFJMT"
    
Map = [[0] * 60 for i in range(30)]

for i in range(30) :
    for j in range(60) :
        Map[i][j] = s[i*30+j]
    
def check(x,y) :
    
    for i,j in [(1,0),(0,1),(0,-1),(-1,0)] :
        px = x + i ; py = y + j
        if ord(Map[x][y]) >= ord(Map[px][py]) : return False
    
    return True
# for i in range(3) :
#     for j in range(5) :
#         print(Map[i][j],end=' ')
#     print()
ans = 0 
    
for i in range(30) :
    for j in range(60) :
        if i == 0 or j == 0 or i == 29 or j == 59 : continue
        if check(i,j) : ans += 1
        
print(ans)

 

7dd87b0df39f4abba375bcda31bc6674.png 

 二位前缀和,枚举起点和终点的横坐标和列坐标即可


Map = [[0] * 101 for i in range(101)]

Map[1][1] = 1 
for i in range(1,101) :
    for j in range(1,101) :
        if i == 1 and j == 1 : continue
        if j == 1 : Map[i][j] = Map[i-1][j] + 1 
        else : Map[i][j] = Map[i][j-1] + 2 
        
for i in range(1,101) :
    for j in range(1,101) :
        Map[i][j] += Map[i-1][j] + Map[i][j-1] - Map[i-1][j-1] 
        
print(Map[3][3])
        
ans = float('inf')

for i in range(1,101) :
    for j in range(i,101) :
        for k in range(1,101) :
            for t in range(k,101) :
                if Map[j][t] - Map[j][k-1] - Map[i-1][t] + Map[i-1][k-1] == 2022 :
                    ans = min(ans,(j-i+1)*(t-k+1))
                    
print(ans)

 

 b75d29531beb4d2c86781e66df38b506.png

模拟 , 签到题


s = int(input())
t = int(input())

ans = 0 
if t > s : print(t - s)
else : print(t + 7 - s)

 

 aa6721c715634eabb486b17907bc268b.png

直接调用replace函数 


s = input()
s = s.replace('a', 'A')
s = s.replace('e', 'E')
s = s.replace('i', 'I')
s = s.replace('o', 'O')
s = s.replace('u', 'U')

print(s)

 ac1227fc247f460f908204e0e473a9d0.png9fc8bccee18148efbcc309cc67035c0d.png

按照输入的顺序,当前的时间-上一个时间✖️电流✖️电压,计算总和 

n = int(input())
ans = 0

for i in range(n) :
    s,U,I = input().split()
    H,M,S = s.split(':')
    if i == 0 :
        oldU = int(U) ; oldI = int(I)
        oldH = int(H) ; oldM = int(M) ; oldS = int(S)
    else :
        ans += ((int(H) - oldH) * 3600 + (int(M) - oldM) * 60 + (int(S) - oldS)) * oldU * oldI
        oldU = int(U) ; oldI = int(I)
        oldH = int(H) ; oldM = int(M) ; oldS = int(S)
        
print(ans)
        
        

 


 22160d4903a44514bde3264249dafddb.png

 

 

c94bb86b2a5e41ad8589316236f5374c.png 

 964eba8eb0f14e258c91ff029d526cf3.png

# 没有思路 


 

 

a8c32f352d474a6c8e179b9828b5a990.png 

 

 8c86aa78c12b4a1cabf12de6ce541ab5.png

# 没有思路 

 

 

 

 

 

最后

以上就是优雅宝贝为你收集整理的第十四届蓝桥杯模拟赛(Python)的全部内容,希望文章能够帮你解决第十四届蓝桥杯模拟赛(Python)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部