| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:dfs之,加个 剪枝即可In Reply To:这题怎么做啊。。没有思路。。 Posted by:Acsaga at 2007-07-26 01:07:24
void dfs(int u, int w)
{
if (u == 2) {
res = lcm(res, w);
return;
}
if (res % w == 0) //重要剪枝
return;
for (L * tmp = adj[u].next; tmp; tmp = tmp->next) {
if (vis[tmp->v] == 0) {
LL g = gcd(w, tmp->w);
vis[tmp->v] = 1;
if (g > 1 && res % g != 0) {
dfs(tmp->v,g);
}
vis[tmp->v] = 0;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator