Skip to content

Commit

Permalink
22.08.24
Browse files Browse the repository at this point in the history
  • Loading branch information
delena0702 authored Aug 24, 2022
1 parent 6384e6a commit 6635fa9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
7 changes: 7 additions & 0 deletions BAEKJOON/10815_숫자_카드.py
Original file line number Diff line number Diff line change
@@ -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()))
10 changes: 10 additions & 0 deletions BAEKJOON/1912_연속합.py
Original file line number Diff line number Diff line change
@@ -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))
23 changes: 23 additions & 0 deletions BAEKJOON/1991_트리_순회.py
Original file line number Diff line number Diff line change
@@ -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='')
23 changes: 23 additions & 0 deletions BAEKJOON/2606_바이러스.py
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions BAEKJOON/2904_수학은_너무_쉬워.py
Original file line number Diff line number Diff line change
@@ -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=' ')

0 comments on commit 6635fa9

Please sign in to comment.