跳到正文

个人记录

newnoder dog

Eterna约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

∑j∈Sdis(i,j)2\displaystyle \sum _{j \in S} \mathrm{dis}(i,j)^2

=∑j∈S[dep(i)+dep(j)−2dep(LCA(i,j))]2=\displaystyle \sum _{j \in S}[\mathrm{dep}(i)+\mathrm{dep}(j)-2\mathrm{dep( LCA}(i,j))]^2

=∑j∈S[dep2(i)+dep2(j)+2dep(i)dep(j)+4dep(LCA(i,j))−2dep(i)dep(LCA(i,j))−2dep(j)dep(LCA(i,j))]\displaystyle =\sum _{j \in S}[\mathrm{dep}^2(i)+\mathrm{dep}^2(j)+2\mathrm{dep}(i)\mathrm{dep}(j)+4\mathrm{dep( LCA}(i,j))-2\mathrm{dep}(i)\mathrm{dep( LCA}(i,j))-2\mathrm{dep}(j)\mathrm{dep( LCA}(i,j))]

=∣S∣dep2(i)+∑j∈Sdep2(j)+2dep(i)∑j∈Sdep(j)+4∑j∈Sdep2(LCA(i,j))−2dep(i)∑j∈Sdep(LCA(i,j))−2∑j∈Sdep(j)dep(LCA(i,j)).\displaystyle = | S | \mathrm{dep}^2(i) + \sum _{j \in S}\mathrm{dep}^2(j) + 2\mathrm{dep}(i)\sum _{j \in S}\mathrm{dep}(j)+4 \sum _{j \in S}\mathrm{dep^2( LCA}(i,j))-2\mathrm{dep}(i) \sum _{j \in S} \mathrm{dep( LCA}(i,j)) -2 \sum _{j \in S} \mathrm{dep}(j)\mathrm{dep( LCA}(i,j)).

原文