摘要:
233. 数字 1 的个数 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 class Solution: def countDigitOne(self, n: int) -> int: s=str(n) @cache def f(i:int,cnt:int,is_lim 阅读全文
posted @ 2024-03-26 20:53
惣聪术
阅读(20)
评论(0)
推荐(0)
摘要:
def z_func(s: str) -> list: n = len(s) z = [0]*(n) l, r = 0, 0 for i in range(1, n): if i < r: z[i] = min(r-i, z[i-l]) while i+z[i] < n and s[z[i]] == 阅读全文
posted @ 2024-03-26 20:36
惣聪术
阅读(21)
评论(0)
推荐(0)
摘要:
SlopeTrick template <typename T> struct Slope { const T INF = std::numeric_limits<T>::max() / 3; T min_f; std::priority_queue<T, std::vector<T>, std:: 阅读全文
posted @ 2024-03-26 20:35
惣聪术
阅读(12)
评论(0)
推荐(0)
摘要:
D - 食塩水 \[\frac{\sum{w_ip_i}}{\sum{w_i}}\ge x \\ \sum{w_i(p_i-x)}\ge 0 \\ \]from collections import * from itertools import * from functools import * 阅读全文
posted @ 2024-03-26 20:11
惣聪术
阅读(44)
评论(0)
推荐(0)
摘要:
D - Gomamayo Sequence 给定 \(N\) 长的01字符串,使其满足,只有一个下标 \(i,S_{i}=S_{i+1}\) 对于 \(S_i\),他改变的花费为 \(C_i\) ,若 \(S_i=0,则它变为1,否则变为0\) 因为只有一对相同的字符组(i,i+1) 维护 \(1- 阅读全文
posted @ 2024-03-26 20:00
惣聪术
阅读(19)
评论(0)
推荐(0)