前段时间学习算法写的一些伪代码
目录并查集费马小定理年份质数全排列DFS快速幂拓扑排序
并查集
用途:找图的回路
Arrays.fill(dset,-1)
合并树根,原图的关联丢失
dset:[n] @fill(-1)
roota=root(a)
rootb=root(b)
if(a!=b)
dset[b] = a //合并
else
... //节点在相同集合时
root(l) =>
while(dset[l]!=-1)
l = dset[l]
return l
费马小定理
a * a(-1)=1(%
原创
2020-10-23 19:45:29 ·
175 阅读 ·
1 评论