From 6635fa9590e690dbee1aa420f0abbadb088a320d Mon Sep 17 00:00:00 2001 From: delena0702 <57484961+delena0702@users.noreply.github.com> Date: Wed, 24 Aug 2022 15:04:28 +0900 Subject: [PATCH] 22.08.24 --- ...3\354\236\220_\354\271\264\353\223\234.py" | 7 ++++ ...2_\354\227\260\354\206\215\355\225\251.py" | 10 ++++++ ...0\353\246\254_\354\210\234\355\232\214.py" | 23 ++++++++++++ ...24\354\235\264\353\237\254\354\212\244.py" | 23 ++++++++++++ ...0\353\254\264_\354\211\254\354\233\214.py" | 35 +++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 "BAEKJOON/10815_\354\210\253\354\236\220_\354\271\264\353\223\234.py" create mode 100644 "BAEKJOON/1912_\354\227\260\354\206\215\355\225\251.py" create mode 100644 "BAEKJOON/1991_\355\212\270\353\246\254_\354\210\234\355\232\214.py" create mode 100644 "BAEKJOON/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" create mode 100644 "BAEKJOON/2904_\354\210\230\355\225\231\354\235\200_\353\204\210\353\254\264_\354\211\254\354\233\214.py" diff --git "a/BAEKJOON/10815_\354\210\253\354\236\220_\354\271\264\353\223\234.py" "b/BAEKJOON/10815_\354\210\253\354\236\220_\354\271\264\353\223\234.py" new file mode 100644 index 0000000..2ebb2f5 --- /dev/null +++ "b/BAEKJOON/10815_\354\210\253\354\236\220_\354\271\264\353\223\234.py" @@ -0,0 +1,7 @@ +import sys +def input(): return sys.stdin.readline().strip() + +N = int(input()) +cards = set(input().split()) +M = int(input()) +print(*map(lambda x: 1 if x in cards else 0, input().split())) \ No newline at end of file diff --git "a/BAEKJOON/1912_\354\227\260\354\206\215\355\225\251.py" "b/BAEKJOON/1912_\354\227\260\354\206\215\355\225\251.py" new file mode 100644 index 0000000..19bc7d1 --- /dev/null +++ "b/BAEKJOON/1912_\354\227\260\354\206\215\355\225\251.py" @@ -0,0 +1,10 @@ +import sys +def input(): return sys.stdin.readline().strip() + +N = int(input()) +data = list(map(int, input().split())) + +dp = [0] * (N) +for i in range(N): + dp[i] = data[i] + max(0, dp[i - 1]) +print(max(dp)) \ No newline at end of file diff --git "a/BAEKJOON/1991_\355\212\270\353\246\254_\354\210\234\355\232\214.py" "b/BAEKJOON/1991_\355\212\270\353\246\254_\354\210\234\355\232\214.py" new file mode 100644 index 0000000..8660c25 --- /dev/null +++ "b/BAEKJOON/1991_\355\212\270\353\246\254_\354\210\234\355\232\214.py" @@ -0,0 +1,23 @@ +import sys +def input(): return sys.stdin.readline().strip() + +def dfs(here): + if here == '.': + return + answer[0].append(here) + dfs(children[here][0]) + answer[1].append(here) + dfs(children[here][1]) + answer[2].append(here) + +N = int(input()) + +children = {} +for _ in range(N): + parent, l, r = input().split() + children[parent] = (l, r) + +answer = [[] for _ in range(3)] +dfs('A') +for i in range(3): + print(*answer[i], sep='') \ No newline at end of file diff --git "a/BAEKJOON/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/BAEKJOON/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..8ac9237 --- /dev/null +++ "b/BAEKJOON/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,23 @@ +from collections import deque +import sys +def input(): return sys.stdin.readline().strip() + +N, M = int(input()), int(input()) + +edges = [[] for _ in range(N + 1)] +for _ in range(M): + a, b = map(int, input().split()) + edges[a].append(b) + edges[b].append(a) + +visited = [False] * (N + 1) +visited[1] = True +queue, answer = deque([1]), -1 +while queue: + here, answer = queue.popleft(), answer + 1 + for there in edges[here]: + if visited[there]: + continue + visited[there] = True + queue.append(there) +print(answer) diff --git "a/BAEKJOON/2904_\354\210\230\355\225\231\354\235\200_\353\204\210\353\254\264_\354\211\254\354\233\214.py" "b/BAEKJOON/2904_\354\210\230\355\225\231\354\235\200_\353\204\210\353\254\264_\354\211\254\354\233\214.py" new file mode 100644 index 0000000..bede93c --- /dev/null +++ "b/BAEKJOON/2904_\354\210\230\355\225\231\354\235\200_\353\204\210\353\254\264_\354\211\254\354\233\214.py" @@ -0,0 +1,35 @@ +import sys +def input(): return sys.stdin.readline().strip() + +is_prime = [True] * (1_000_001) +primes = [] +for i in range(2, 1_000_001): + if not is_prime[i]: + continue + primes.append(i) + for j in range(2 * i, 1_000_001, i): + is_prime[j] = False + +N, data = int(input()), list(map(int, input().split())) + +count = [0] * (len(primes)) +for num in data: + for i, prime in enumerate(primes): + if num == 1: + break + while num % prime == 0: + num, count[i] = num // prime, count[i] + 1 + +answer = [1, 0] +for i in range(len(primes)): + if count[i]: + answer[0] = answer[0] * (primes[i] ** (count[i] // N)) + +for i, prime in enumerate(primes): + for num in data: + cnt = 0 + while num % prime == 0: + num, cnt = num // prime, cnt + 1 + answer[1] = answer[1] + max(0, count[i] // N - cnt) + +print(*answer, sep=' ')