cf839c Journey
大水题
#include <iostream>
#include <cstdio>
using namespace std;
int n, du[100005], hea[100005], cnt, uu, vv;
double dp[100005];
struct Edge{
int too, nxt;
}edge[200005];
void add_edge(int fro, int too){
edge[++cnt].nxt = hea[fro];
edge[cnt].too = too;
hea[fro] = cnt;
}
void dfs(int x, int f){
for(int i=hea[x]; i; i=edge[i].nxt){
int t=edge[i].too;
if(t!=f){
dfs(t, x);
dp[x] += (dp[t] + 1.0) / du[x];
}
}
}
int main(){
cin>>n;
for(int i=1; i<n; i++){
scanf("%d %d", &uu, &vv);
add_edge(uu, vv);
add_edge(vv, uu);
du[uu]++;
du[vv]++;
}
for(int i=2; i<=n; i++)
du[i]--;
dfs(1, 0);
printf("%lf", dp[1]);
return 0;
}
cf839c Journey的更多相关文章
- CF721C. Journey[DP DAG]
C. Journey time limit per test 3 seconds memory limit per test 256 megabytes input standard input ou ...
- POJ2488A Knight's Journey[DFS]
A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41936 Accepted: 14 ...
- CF #374 (Div. 2) C. Journey dp
1.CF #374 (Div. 2) C. Journey 2.总结:好题,这一道题,WA,MLE,TLE,RE,各种姿势都来了一遍.. 3.题意:有向无环图,找出第1个点到第n个点的一条路径 ...
- POJ2488-A Knight's Journey(DFS+回溯)
题目链接:http://poj.org/problem?id=2488 A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Tot ...
- codeforces 721C C. Journey(dp)
题目链接: C. Journey time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...
- A Knight's Journey 分类: POJ 搜索 2015-08-08 07:32 2人阅读 评论(0) 收藏
A Knight's Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 35564 Accepted: 12119 ...
- HDOJ-三部曲一(搜索、数学)- A Knight's Journey
A Knight's Journey Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) ...
- 【推公式】UVa 10995 - Educational Journey
1A~,但后来看人家的代码好像又写臭了,T^T... Problem A: Educational journey The University of Calgary team qualified f ...
- poj 3544 Journey with Pigs
Journey with Pigs Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3004 Accepted: 922 ...
随机推荐
- 排序二叉树 HDOJ 5444 Elven Postman
题目传送门 题意:给出线性排列的树,第一个数字是根节点,后面的数如果当前点小或相等往左走,否则往右走,查询一些点走的路径 分析:题意略晦涩,其实就是排序二叉树!1<<1000 普通数组开不 ...
- 1-1-Java的特点
Java语言平台 JavaSE(Java Platform Standard Edition)标准版 以前叫做J2SE,5.0版本后改名叫做JAVASE,主要用于桌面应用程序的开发,该技术体系是后两者 ...
- servlet service的描述:
链接:https://www.nowcoder.com/questionTerminal/3f368578e43d48b1968d79b935d00972来源:牛客网 1. service方法 ...
- Smart 组件 vs Dumb 组件
大家已经知道,只会接受 props 并且渲染确定结果的组件我们把它叫做 Dumb 组件,这种组件只关心一件事情 —— 根据 props 进行渲染. Dumb 组件最好不要依赖除了 React.js 和 ...
- 23中java设计模式(1)-- 策略模式
近来不太忙,就打算抽空看下源码补充一下知识,当我看了之后我发现看源码的关键是要弄清楚类之家的关系以及为何要这样的关系,否则如果只看具体的代码那不如去学习会儿算法. 于是就打算从设计模式入手,边学习边记 ...
- JavaScript——数组的indexOf()方法在IE8中的兼容性问题
昨天在工作中遇到一个问题:数组的indexOf()方法在IE8中无效. 如以下代码在IE8中报错“对象不支持“indexOf”属性或方法”: var arr = [1,2,3]; var index ...
- Git之远程项目克隆到本地配置
远程代码克隆到本地工作区,需要进行简单的配置,用于识别身份 1.git config --global user.name [设置用户名,你的github用户名] 2.git config -- ...
- NYOJ 题目42 一笔画问题
一笔画问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 zyc从小就比较喜欢玩一些小游戏,其中就包括画一笔画,他想请你帮他写一个程序,判断一个图是否能够用一笔画下 ...
- HTML5应用 + Cordova = 平台相关的混合应用
Jerry之前的一篇文章 SAP Fiori应用的三种部署方式 曾经提到SAP Fiori应用的三种部署方式: On Premise环境下以ABAP BSP应用作为Fiori应用部署和运行的载体 部署 ...
- 11G GI启动顺序
--11gR2 Clusterware and Grid Home - What You Need to Know (文档 ID 1053147.1) 上图来自<Oracle C ...