Brief Description 求\(K_{n,m}\) Algorithm Design 首先我们有(Matrix Tree)定理,可以暴力生成几组答案,发现一些规律: \[K_{n,m} = n^{m-1} * m^{n-1}\] 然而直接乘法会爆longlong,所以使用快速乘 Code #include <cstdio> #define ll long long ll n, m, p; inline ll mul(ll a, ll b) { ll x = 0; while (b)…
In some countries building highways takes a lot of time... Maybe that's because there are many possiblities to construct a network of highways and engineers can't make up their minds which one to choose. Suppose we have a list of cities that can be c…