无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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;

}


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

分享到微博請遵守國家法律
宣城市| 蓝田县| 舒兰市| 凤阳县| 永靖县| 沙洋县| 曲松县| 兴业县| 定兴县| 阿瓦提县| 湟中县| 南投市| 龙泉市| 阳城县| 南宫市| 体育| 兴文县| 汕头市| 龙游县| 长治县| 仁布县| 普宁市| 大连市| 凤冈县| 开封县| 依兰县| 华亭县| 万年县| 长泰县| 中西区| 正定县| 湖北省| 读书| 阳新县| 巴南区| 西丰县| 广宁县| 博湖县| 阜南县| 忻城县| 澜沧|