描述
An undirected graph is a set V of vertices and a set of E∈{V*V} edges.An undirected graph is connected if and only if for every pair (u,v) of vertices,u is reachable from v.
You are to write a program that tries to calculate the number of different connected undirected graph with n vertices.
For example,there are 4 different connected undirected graphs with 3 vertices.
题解:
这就是NOIP2017提高组初赛选择题第8题……考场上用排列组合算的,结果这道题就不会做了……答案可以用总情况-不合法情况。令
f[i]
表示
i
个点连通的方案数,
g[i]=∑k=1i−1Ck−1i−1×f[k]×2C2n−k
f[i]=C2i−g[i]