摘要:
Huffman编码树 贪心地可知,Huffman编码的方式可使题目所求式子最小。 import heapq n=int(input()) a=list(map(int,input().split())) q=[] for i in a: heapq.heappush(q,i) ans=0 while 阅读全文
摘要:
最小新整数 单调栈 t=int(input()) for _ in range(t): n,k=input().split() k=int(k) m=len(n) s=[] cnt=0 for c in n: while(s and c<s[-1] and cnt<k): s.pop() cnt+= 阅读全文
摘要:
May the force be with you 2026.5.3 估计直径 先采取O(n)方法得到一个直径的2-近似T,然后格点化。作\(l=\epsilon *T / \sqrt{2}\)的网格,并round到中心,因此每个点移动的距离小于\(\epsilon * diam(P)\).对网格代 阅读全文
摘要:
:你说不会今天没有月考吧 -六道正常题目 :今天没有骗你何尝不是一种骗到你了 反反复复 代码复用这一块。 n=int(input()) a=list(input()) a.insert(0," ") for i in range(1,n+1): for j in range(1,len(a)): i 阅读全文
摘要:
从上学期就开始说的打比赛不要急是什么意思! 就是T2被卡了,以及T6交的前两发输出格式都不对。 泰波拿契數 n=int(input()) a=[0,1,1] for i in range(3,n+1): a.append(a[i-1]+a[i-2]+a[i-3]) print(a[n]) 稳定的符文 阅读全文
摘要:
2026.3.1 相交链表 from typing import Optional:返回目标类型或None 一个链表为a+c,另一个链表为b+c。走完一个开始走另一个,最终两个指针都走a+b+c,并在相交点相遇。 from typing import Optional class ListNode: 阅读全文