반응형
물이 멈추는 구간은 leaf일 때 뿐이므로 입력 시 leaf만 세준다. 그 후 소수점 10자리 출력
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int u, v, n;
double cnt,w;
int a[500001];
//1번노드에 들어가 있는 물의 양
int main() {
cin >> n >> w;
for(int i = 1 ; i<=n-1; i++)
{
cin >> u >> v;
a[u]++;
a[v]++;
}
for (int i = 2; i <= n; i++)
{
if (a[i] == 1)
{
cnt++;
}
//cout << a[i] << ' ';
}
printf("%.10f", w / cnt);
}
|
cs |
'Algorithm' 카테고리의 다른 글
(C++) - 백준(BOJ) 11969번 : Breed Counting (0) | 2019.06.20 |
---|---|
(C++) - 백준(BOJ) 17127번 : 벚꽃이 정보섬에 피어난 이유 (0) | 2019.06.18 |
(C++) - 백준(BOJ) 17141번 : 연구소 2 (0) | 2019.05.20 |
(C++) - 백준(BOJ) 17141번 : 연구소 (0) | 2019.05.19 |
(C++) - 백준(BOJ) 9613번 : GCD합 (2) | 2019.05.02 |