We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 59ee5a7 commit 39b296dCopy full SHA for 39b296d
live10/test108/문제3/백한결.py
@@ -0,0 +1,33 @@
1
+import sys
2
+from collections import defaultdict
3
+
4
+sys.setrecursionlimit(10**6)
5
+count = 0
6
7
+def main():
8
+ input = sys.stdin.readline
9
+ N, W = map(int, input().split())
10
11
+ tree = defaultdict(list)
12
13
+ for _ in range(N-1):
14
+ u, v = map(int, input().split())
15
+ tree[u].append(v)
16
+ tree[v].append(u)
17
18
+ def dfs(node, parent):
19
+ global count
20
+ isLeaf = True
21
+ for child in tree[node]:
22
+ if child != parent:
23
+ isLeaf = False
24
+ dfs(child, node)
25
+ if isLeaf:
26
+ count += 1
27
28
+ dfs(1, -1)
29
30
+ print(W / count)
31
32
+if __name__ == '__main__':
33
+ main()
0 commit comments