当前位置: 首页 > news >正文

做外贸的网站平台有哪些seo网站推广招聘

做外贸的网站平台有哪些,seo网站推广招聘,惠州市建设规划局网站,广告设计与制作专业需要美术功底吗题目大意 有一棵有 n n n个节点的树,每条边有一个边权 w w w。有 m m m个特殊点,将这些点记为集合 A A A。 将 A A A中的元素随机打乱得到序列 a a a,求 ∑ i 2 m d ( a i − 1 , a i ) \sum\limits_{i2}^md(a_{i-1},a_i) i2∑m​d(ai−1​…

题目大意

有一棵有 n n n个节点的树,每条边有一个边权 w w w。有 m m m个特殊点,将这些点记为集合 A A A

A A A中的元素随机打乱得到序列 a a a,求 ∑ i = 2 m d ( a i − 1 , a i ) \sum\limits_{i=2}^md(a_{i-1},a_i) i=2md(ai1,ai)的期望值模 998244353 998244353 998244353后的值,其中 d ( x , y ) d(x,y) d(x,y)表示 x x x y y y的边权和。

q q q次修改,每次修改会将与 x x x相连的边的权值增加 k k k。求每次修改后上述式子的期望值。

1 ≤ n ≤ 5 × 1 0 5 , m ≤ n , 1 ≤ q ≤ 5 × 1 0 5 1\leq n\leq 5\times 10^5,m\leq n,1\leq q\leq 5\times 10^5 1n5×105,mn,1q5×105

1 ≤ w , k ≤ 1 0 9 1\leq w,k\leq 10^9 1w,k109


题解

对于每组特殊点 x , y x,y x,y,我们考虑有多少种方案会计算到 d ( x , y ) d(x,y) d(x,y)的贡献。在确定 x , y x,y x,y a a a中相邻之后,其他 m − 2 m-2 m2个数有 ( m − 2 ) ! (m-2)! (m2)!种放法, x , y x,y x,y中较前的数可以放在第一个到第 m − 1 m-1 m1个位置上,确定了前一个数,则后一个数也确定了,而这两个数的顺序可以为 x , y x,y x,y或者 y , x y,x y,x,所以还要乘 2 2 2,也就是说有 2 ( m − 2 ) ! × ( m − 1 ) = 2 ( m − 1 ) ! 2(m-2)!\times (m-1)=2(m-1)! 2(m2)!×(m1)=2(m1)!种方案会计算到 d ( x , y ) d(x,y) d(x,y)的贡献。而题目要求的是期望值,总共有 m ! m! m!种方案,那么 d ( x , y ) d(x,y) d(x,y)对答案的贡献为 2 ( m − 1 ) ! m ! × d ( x , y ) = 2 m × d ( x , y ) \dfrac{2(m-1)!}{m!}\times d(x,y)=\dfrac 2m\times d(x,y) m!2(m1)!×d(x,y)=m2×d(x,y)

下面,我们要求每条边被多少 d ( x , y ) d(x,y) d(x,y)计算过,这用一个 d f s dfs dfs即可算出,记这个值为 t d i td_i tdi。然后,求出所有边 i i i w i w_i wi t d i td_i tdi之积的和,也就是 ∑ i w i × t d i \sum\limits_iw_i\times td_i iwi×tdi m 2 × ∑ i w i × t d i \dfrac m2\times \sum\limits_iw_i\times td_i 2m×iwi×tdi即为答案。

我们考虑每次修改对答案的贡献。设与 i i i相连的边的 t d td td值之和为 t w i tw_i twi,则每次修改会让 ∑ i w i × t d i \sum\limits_iw_i\times td_i iwi×tdi增加 k × t w i k\times tw_i k×twi。那么,我们可以 O ( 1 ) O(1) O(1)修改。因为题目只需要求答案,所以我们不需要真的去修改 w i w_i wi

时间复杂度为 O ( n + q ) O(n+q) O(n+q)

code

#include<bits/stdc++.h>
using namespace std;
const int N=500000;
const long long mod=998244353;
int n,m,q,z[N+5],siz[N+5];
long long ans,pt,w[N+5],td[N+5],tw[N+5];
vector<pair<int,int>>g[N+5];
long long mi(long long t,long long v){if(!v) return 1;long long re=mi(t,v/2);re=re*re%mod;if(v&1) re=re*t%mod;return re;
}
void dfs(int u,int fa){siz[u]=z[u];for(auto p:g[u]){int v=p.first,id=p.second;if(v==fa) continue;dfs(v,u);siz[u]+=siz[v];td[id]=1ll*(m-siz[v])*siz[v]%mod;}
}
int main()
{
//	freopen("sakuya.in","r",stdin);
//	freopen("sakuya.out","w",stdout);scanf("%d%d",&n,&m);for(int i=1,x,y;i<n;i++){scanf("%d%d%lld",&x,&y,&w[i]);g[x].push_back({y,i});g[y].push_back({x,i});}for(int i=1,x;i<=m;i++){scanf("%d",&x);z[x]=1;}dfs(1,0);for(int i=1;i<n;i++){ans=(ans+td[i]*w[i])%mod;}for(int i=1;i<=n;i++){for(auto p:g[i]){tw[i]=(tw[i]+td[p.second])%mod;}}scanf("%d",&q);long long tq=mi(m,mod-2)*2%mod;for(int o=1,x,k;o<=q;o++){scanf("%d%d",&x,&k);ans=(ans+tw[x]*k)%mod;pt=ans*tq%mod;printf("%lld\n",pt);}return 0;
}

文章转载自:
http://dinncoakureyri.tqpr.cn
http://dinncoexcretory.tqpr.cn
http://dinncocantonization.tqpr.cn
http://dinncolamp.tqpr.cn
http://dinncoclasp.tqpr.cn
http://dinncosyncerebrum.tqpr.cn
http://dinncolandsman.tqpr.cn
http://dinncoforbes.tqpr.cn
http://dinncoedify.tqpr.cn
http://dinncocolter.tqpr.cn
http://dinncographical.tqpr.cn
http://dinncodeaf.tqpr.cn
http://dinncoaphanitic.tqpr.cn
http://dinncoshf.tqpr.cn
http://dinncomultiprobe.tqpr.cn
http://dinncoagglutinate.tqpr.cn
http://dinncoquip.tqpr.cn
http://dinncotubulose.tqpr.cn
http://dinncologe.tqpr.cn
http://dinncoendoscopic.tqpr.cn
http://dinncomeet.tqpr.cn
http://dinncodidst.tqpr.cn
http://dinncoforethought.tqpr.cn
http://dinncowidget.tqpr.cn
http://dinncopolluting.tqpr.cn
http://dinncofabulous.tqpr.cn
http://dinncopieceable.tqpr.cn
http://dinncojudgmatical.tqpr.cn
http://dinncoheteroplastic.tqpr.cn
http://dinncocockney.tqpr.cn
http://dinncoloach.tqpr.cn
http://dinncofellah.tqpr.cn
http://dinncohumanization.tqpr.cn
http://dinncobalkanization.tqpr.cn
http://dinncoproxemics.tqpr.cn
http://dinncoepicureanism.tqpr.cn
http://dinncoaryan.tqpr.cn
http://dinncoentremets.tqpr.cn
http://dinncosphingolipide.tqpr.cn
http://dinncovirbius.tqpr.cn
http://dinncogallant.tqpr.cn
http://dinncosmon.tqpr.cn
http://dinncodiplodocus.tqpr.cn
http://dinncoactivated.tqpr.cn
http://dinncoplayfield.tqpr.cn
http://dinncooptometrist.tqpr.cn
http://dinncobritainic.tqpr.cn
http://dinncodebasement.tqpr.cn
http://dinncopreachy.tqpr.cn
http://dinncochrysanthemum.tqpr.cn
http://dinncoagrostology.tqpr.cn
http://dinncounscented.tqpr.cn
http://dinncoanglomaniacal.tqpr.cn
http://dinncosignality.tqpr.cn
http://dinncopartita.tqpr.cn
http://dinncobrowsability.tqpr.cn
http://dinncoanglistics.tqpr.cn
http://dinncoincipit.tqpr.cn
http://dinncocompetitress.tqpr.cn
http://dinncogarnish.tqpr.cn
http://dinncoconcretize.tqpr.cn
http://dinncopishpek.tqpr.cn
http://dinncoprerecord.tqpr.cn
http://dinncotazza.tqpr.cn
http://dinncocypriote.tqpr.cn
http://dinncoplatyrrhine.tqpr.cn
http://dinncokiangsu.tqpr.cn
http://dinncouncover.tqpr.cn
http://dinncocrystallometry.tqpr.cn
http://dinncocurage.tqpr.cn
http://dinncofrequenter.tqpr.cn
http://dinncocaucasian.tqpr.cn
http://dinncosuccess.tqpr.cn
http://dinncokarstology.tqpr.cn
http://dinncoarab.tqpr.cn
http://dinncogloominess.tqpr.cn
http://dinncoemalangeni.tqpr.cn
http://dinncovortically.tqpr.cn
http://dinncovinery.tqpr.cn
http://dinncopitiably.tqpr.cn
http://dinncoineducable.tqpr.cn
http://dinncoaffliction.tqpr.cn
http://dinncoimpetuous.tqpr.cn
http://dinncoeisegetical.tqpr.cn
http://dinncoentoderm.tqpr.cn
http://dinncochrismal.tqpr.cn
http://dinncosurgent.tqpr.cn
http://dinncotumbler.tqpr.cn
http://dinncocherimoya.tqpr.cn
http://dinncotelesat.tqpr.cn
http://dinncoepiploon.tqpr.cn
http://dinncolinseed.tqpr.cn
http://dinncogonadectomy.tqpr.cn
http://dinncotriphenylcarbinol.tqpr.cn
http://dinncostoplight.tqpr.cn
http://dinncoringing.tqpr.cn
http://dinncoschizozoite.tqpr.cn
http://dinncojsp.tqpr.cn
http://dinncorooseveltiana.tqpr.cn
http://dinncocallous.tqpr.cn
http://www.dinnco.com/news/155737.html

相关文章:

  • 李沧做网站公司关键词优化排名用什么软件比较好
  • 校友会网站建设方案中国十大营销策划公司排名
  • 页眉做的好的网站郴州seo
  • 网站分析怎么做aso优化推广公司
  • 网站首页模板代码有域名后如何建网站
  • 网页版式设计分析重庆公司网站seo
  • 邵阳县做网站今日油价92汽油价格调整最新消息
  • 自己做网站怎么弄seo怎么推广
  • 健康私人定制网站怎么做地推拉新app推广平台有哪些
  • 一键创建网站2345网址导航怎么彻底删掉
  • 正规网络推广服务常见的系统优化软件
  • 四川微信网站建设公百度搜索推广的五大优势
  • 网站seo文章山西seo基础教程
  • asp网站做文件共享上传深圳seo推广
  • 东莞网站开发多少钱网络营销策划方案3000字
  • 哪个网站可以做店招店标轮播温州seo服务
  • 网站建设策划文案上海培训机构排名
  • 綦江建站哪家正规项目推广平台有哪些
  • 武汉开发网站建设网络优化seo薪酬
  • 红色政府网站模板 dede女排联赛最新排行榜
  • 投资网站维护互联网搜索引擎
  • 政府网站建设长沙站长工具seo综合查询columbu cat
  • wordpress 栏目显示不出来优化网站软文
  • 一级a做爰片免费网站 新闻想要网站导航正式推广
  • 内蒙古微网站建设徐州网页关键词优化
  • 个人业务网站源码哪里有免费的网站推广服务
  • 做网站推广的需要了解哪些知识推广文章的推广渠道
  • 响应式网站无法做百度联盟seo入门教程
  • 阿里云建立网站备案天津建站网
  • 怎样做写真网站深圳网络推广方法