其他分享
首页 > 其他分享> > CF696B Puzzles 概率期望

CF696B Puzzles 概率期望

作者:互联网

code: 

#include <bits/stdc++.h>   
#define N 100005 
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std;      
int n,edges;  
double f[N]; 
int hd[N],to[N<<1],nex[N<<1],size[N]; 
void add(int u,int v) 
{
	nex[++edges]=hd[u],hd[u]=edges,to[edges]=v; 
} 
void dfs1(int u,int ff) 
{
	size[u]=1; 
	for(int i=hd[u];i;i=nex[i]) 
	    if(to[i]!=ff) dfs1(to[i],u), size[u]+=size[to[i]];   
} 
void dfs2(int um)
int main() 
{ 
    setIO("input");          
	int i,j;      
	scanf("%d",&n);    
	for(i=1;i<n;++i) 
	{        
		int u,v; 
		scanf("%d%d",&u,&v);  
		add(u,v), add(v,u); 
	} 
	dfs1(1,0); 
	return 0; 
}

  

标签:std,100005,期望,int,double,CF696B,Puzzles,edges,define
来源: https://www.cnblogs.com/guangheli/p/11794842.html