蓝桥杯刷题--python-16

562. 壁画 - AcWing题库

T=int(input())

j=1

while(j<=T):

N = int(input())

a=input()

s = [0]*(N+1)

求前戳和

for i in range(1, N + 1):

s[i] = int(a[i-1]) + s[i - 1]

枚举

区间

max_ = float('-inf')

k = (N + 2 - 1) // 2

for i in range(k, N + 1):

tmp_ = s[i] - s[i - k]

max_ = max(tmp_, max_)

print(f'Case #{j}: {max_}')

j += 1

4956. 冶炼金属 - AcWing题库

N=int(input())

V_min=float("-inf")

V_max=float("inf")

for _ in range(N):

A,B=map(int,input().split())

V_min=max(V_min,(A//(B+1))+1)

V_max=min(V_max,(A//B))

print(V_min,V_max)

N=int(input())

V_min=float("-inf")

V_max=float("inf")

def check(A,B):

l=1

r=10**9+1

while(l<r):

mid=l+r>>1

if (A//mid<=B):

r=mid

else:

l=mid+1

return r

for _ in range(N):

A,B=map(int,input().split())

V_min=max(V_min,check(A,B))

V_max=min(V_max,check(A,B-1)-1)

print(V_min,V_max)

相关推荐
_.Switch3 分钟前
Python Web 应用中的 API 网关集成与优化
开发语言·前端·后端·python·架构·log4j
一个闪现必杀技21 分钟前
Python入门--函数
开发语言·python·青少年编程·pycharm
小鹿( ﹡ˆoˆ﹡ )42 分钟前
探索IP协议的神秘面纱:Python中的网络通信
python·tcp/ip·php
卷心菜小温1 小时前
【BUG】P-tuningv2微调ChatGLM2-6B时所踩的坑
python·深度学习·语言模型·nlp·bug
陈苏同学1 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
唐家小妹1 小时前
介绍一款开源的 Modern GUI PySide6 / PyQt6的使用
python·pyqt
羊小猪~~2 小时前
深度学习项目----用LSTM模型预测股价(包含LSTM网络简介,代码数据均可下载)
pytorch·python·rnn·深度学习·机器学习·数据分析·lstm
Tisfy2 小时前
LeetCode 2187.完成旅途的最少时间:二分查找
算法·leetcode·二分查找·题解·二分
Marst Code2 小时前
(Django)初步使用
后端·python·django
985小水博一枚呀3 小时前
【对于Python爬虫的理解】数据挖掘、信息聚合、价格监控、新闻爬取等,附代码。
爬虫·python·深度学习·数据挖掘