蓝桥杯刷题--python-21

1343. 挤牛奶 - AcWing题库

n=int(input())

a=\[\]

max_j=0

max_nj=0

for _ in range(n):

s,e=list(map(int,input().split()))

a.append(s,e)

print(a)

区间合并

a=sorted(a,key=lambda x:x0)

merged=\[\]

for interval in a:

if not merged:

merged.append((interval))

max_j=interval1-interval0

elif interval0>merged-1-1:

max_nj = max(max_nj, interval0 - merged-1-1)

merged.append((interval))

else:

merged-1-1=max(merged-1-1,interval1)

max_j=max(max_j,merged-1-1-merged-10)

max_j=max(max_j,merged-1-1-merged-10)

print(f'{max_j} {max_nj}')

1360. 有序分数 - AcWing题库

def gcd(a, b):

while b:

a, b = b, a % b

return a

n = int(input())

res = \[\]

for i in range(n + 1):

for j in range( i + 1):

if gcd(i, j) == 1:

res.append(i, j)

res.sort(key=lambda x:x1/x0)

for i in res:

print(f'{i1}/{i0}')

复制代码
n=int(input())


def dfs(a,b,c,d):
    if (a+c>n): return
    dfs(a,b,a+c,b+d)
    print(f'{b+d}/{a+c}')
    dfs(a+c,b+d,c,d)

print("0/1")
dfs(1,0,1,1)
print("1/1")
相关推荐
花酒锄作田6 小时前
Pydantic校验配置文件
python
hboot7 小时前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi17 小时前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi19 小时前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽19 小时前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户83580861879120 小时前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L2 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅2 天前
海天线算法的前世今生
python·计算机视觉
韩师傅2 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L2 天前
LangGraph的MessageState and HumanMessage
python