AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
题意n个点的树k种颜色,距离不超过2的点对需颜色不同,求方案数Code(copy)#include#include#include#include#includetypedeflonglongLL;constintN=100005;constintMOD=1000000007;intn,k,jc[N],ny[N],ans,cnt,last[N];structedge{intto,next;}e[N