蓝桥杯刷题--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)

相关推荐
青春不朽51244 分钟前
Scrapy框架入门指南
python·scrapy
MZ_ZXD0011 小时前
springboot旅游信息管理系统-计算机毕业设计源码21675
java·c++·vue.js·spring boot·python·django·php
全栈老石2 小时前
Python 异步生存手册:给被 JS async/await 宠坏的全栈工程师
后端·python
梨落秋霜2 小时前
Python入门篇【模块/包】
python
阔皮大师3 小时前
INote轻量文本编辑器
java·javascript·python·c#
小法师爱分享3 小时前
StickyNotes,简单便签超实用
java·python
深蓝电商API3 小时前
处理字体反爬:woff字体文件解析实战
爬虫·python
开源技术3 小时前
Claude Opus 4.6 发布,100万上下文窗口,越贵越好用
人工智能·python
张3蜂3 小时前
深入理解 Python 的 frozenset:为什么要有“不可变集合”?
前端·python·spring
皮卡丘不断更4 小时前
手搓本地 RAG:我用 Python 和 Spring Boot 给 AI 装上了“实时代码监控”
人工智能·spring boot·python·ai编程