您当前的位置: 首页 >  ar

先求一个导

暂无认证

  • 2浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

P2986 [USACO10MAR] Great Cow Gathering G (学学换根dp)

先求一个导 发布时间:2022-03-31 22:15:01 ,浏览量:2

题目 题意: 给定n个点的树,每个点有对应的点权。选中一个点,满足所有点到其的点权*距离之和最小,输出对应的最小值。 思路: 还是最基础的换根dp,只不过和上一个题相比多了边权和点权,注意边权不是1就行。 时间复杂度: O(n) 代码:

// Problem: P2986 [USACO10MAR] Great Cow Gathering G
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2986
// Memory Limit: 128 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i            
关注
打赏
1662037414
查看更多评论
0.0423s