Skip to content

Commit de0f02f

Browse files
Merge pull request #703 from baekhangyeol/main
[백한결] 108차 라이브 코테 제출
2 parents f5c335f + 39b296d commit de0f02f

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def main():
2+
expression = input()
3+
numList = expression.split('-')
4+
totalSum = 0
5+
totalMinus = []
6+
7+
8+
for i in numList[0].split('+'):
9+
totalSum += int(i)
10+
11+
for i in range(1, len(numList)):
12+
totalMinus.append(numList[i].split('+'))
13+
14+
for j in totalMinus.pop():
15+
totalSum -= int(j)
16+
17+
print(totalSum)
18+
19+
if __name__ == "__main__":
20+
main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def main():
2+
N, K = map(int, input().split())
3+
dp = [[0] * (N + 1) for _ in range(K + 1)]
4+
5+
for i in range(K + 1):
6+
dp[i][0] = 1
7+
8+
for i in range(1, K + 1):
9+
for j in range(1, N + 1):
10+
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000000
11+
12+
print(dp[K][N])
13+
14+
15+
16+
if __name__ == '__main__':
17+
main()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)