P4186 [USACO18JAN]Cow at Large G(树形DP) Luogu4186 设dp[i]表示i点需要放多少个农民.则有 \(if(near[i]-dep[i]<=dep[i]-1)\ dp[i]=1;\) \(else\ dp[i]=\sum dp[son[i]]\) AC代码 转载于:https://www.cnblogs.com/lizehon/p/10479137.html