0%

树上dp

什么是树上dp?字面意思,在树上做dp

但是这个描述不准确,更准确应该是树形dp,树上dp可能只是在树上,有一个dp,不一定是树状转移状态的

状态转移的方向:自顶向下/自底向上

自顶向下需要为根节点设计初始状态,自底向上需要为所有叶子节点设计初始状态,这里可能是不同的

一个自顶向下的例子:树上差分/前缀和

自顶向下时一个结点的多个子结点会共用一个dp状态栈,所以需要利用回溯的性质

自底向上时一个结点会从多个子结点来转移状态,所以状态转移方程会更复杂;且子结点树可能是\(O(n)\)的,对于关于子结点数\(k\)时间复杂度\(\Omega(k^{1+\epsilon})\)的转移计算方法,菊花树会爆,此时要考虑在子结点上做一些操作比如排序/在子结点上维护数据结构/启发式合并状态/设计逐结点转移方程/拆点拆边

Read more »

Abstract

This article develops the exponential and trigonometric functions from first principles using infinite series, avoiding
reliance on geometric intuition or pre-existing notions of angle. Motivated by foundational concerns raised in early
twentieth-century analysis, the construction is carried out directly on the complex plane. After establishing the
algebraic structure and completeness of as a normed vector space, basic results on complex series are proved,
including absolute convergence and a Fubini-type theorem. The exponential function is then defined by its power series,
shown to be well-defined on , and its fundamental properties—such as the exponent law, positivity on , and
monotonicity—are derived. Trigonometric functions are introduced via the complex exponential, leading naturally to
Euler’s formula, addition formulas, and the Pythagorean identity. This approach demonstrates that the classical
properties of exponential and trigonometric functions arise purely from analytic and algebraic considerations, without
geometric assumptions.

Read more »

\newcommand {\w} {\omega}

\newcommand {\W} {\Omega}

\newcommand {\e} {\varepsilon}

\newcommand {\p} {\psi}

\newcommand {\f} {\varphi}

\newcommand {\z} {\zeta}

\newcommand {\G} {\Gamma}

\newcommand {\a} {\alpha}

Mainly using BOCF with , the recursive Mahlo ordinal. For ordinals less than , normal
notation with extended Veblen’s function is also used.

Contents:

  1. part 1, to
  2. part 2, to
  3. part 3, to
  4. part 4, to
  5. part 5, to
Read more »

ACMOJ链接

形式化题意

给定长度为 的字母序列 ,和长度为 的字母序列 ,求 中和
相似的子串有多少个,相似代表离散化后一致,即每一个对应位置字符的序关系保持一致。

Read more »

原知乎回答

前言

两年前一位姚班大神学长回到高中母校并出了这样一道题:抢红包。

个人抢价值 元的红包,手气最佳同学抢到的红包的期望是多少?

注意这里是最大值,而最大值问题其实要比最小值问题难。当时我硬用积分和一些奇技淫巧给出了最小值的解答——
。而后大神给出了一个非常漂亮的解答,在这个解答中给出了任意排名的红包期望值。

为了尽量严谨化题意,他给出了一个等价的问题:

一段长为 的环形绳子,随机地切 刀,最长的一段长度的期望是多少?

Read more »