最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

牛客競賽題目講解_孤獨的樹

2022-05-01 10:37 作者:Clayton_Zhou  | 我要投稿

// https://ac.nowcoder.com/acm/contest/11225/F


#include "stdafx.h"

//#include <bits/stdc++.h>

#include <algorithm>

#include <iostream>

#include <cstring>

?#include <vector>



using namespace std;

int n,i,j;

?

int a[100005]={0,32,2,2,2,2};

int edge[32][2]={

1, 2,

1, 3,

1, 4,

1,5

};


vector<int> v[100005];

int ans;

?int gcd(int a,int b)

{? ??

? ? if(a%b==0)?

? ? return b;? ? ? ??

? ? else return (gcd(b,a%b));

}

int pcount(int t)

{

if(t==1)return 0;

int pc=0;?

? for(int i=2;t>1;i++)? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? while(t%i==0)t/=i,pc++;? ?? ? ??

? return pc;

}

void dfs(int x,int fa){

? ? for(int y:v[x])if(y!=fa){

? ? ? ? dfs(y,x);

? ? ? ? int t=gcd(a[x],a[y]);

? ? ? ? ans+=pcount(t);

? ? ? ? a[x]/=t;

cout<<" a[x]="<<a[x]<<"? t="<<t<<endl;

? ? }

}

int main()

{

n=5;

? ? //cin>>n;

? ?// for(int i=1;i<=n;i++)cin>>a[i];?

? ? for(int i=1;i<n;i++){

? ? ? ? int x,y;

x=edge[i-1][0];

y=edge[i-1][1];

? ? ? ? //cin>>x>>y;

? ? ? ? v[x].push_back(y);

? ? ? ? v[y].push_back(x);

? ? }

? ? ?dfs(1,0);

? ? cout<<ans<<endl;

? ? return 0;

}


??透傎愵}目講解_孤獨的樹的評論 (共 條)

分享到微博請遵守國家法律
纳雍县| 邢台市| 韩城市| SHOW| 临沭县| 沭阳县| 东丽区| 慈利县| 兰西县| 广昌县| 庆元县| 自贡市| 兰州市| 错那县| 东明县| 定安县| 邵阳县| 苏尼特右旗| 东光县| 贵定县| 乾安县| 独山县| 台东市| 梧州市| 昂仁县| 大渡口区| 富宁县| 水富县| 陵川县| 新竹县| 枞阳县| 武乡县| 家居| 裕民县| 诸城市| 丹寨县| 梅州市| 五台县| 辉县市| 望城县| 南昌市|