diff --git "a/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/1\353\241\234\353\247\214\353\223\244\352\270\260.py" "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/1\353\241\234\353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..cf160ef --- /dev/null +++ "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/1\353\241\234\353\247\214\353\223\244\352\270\260.py" @@ -0,0 +1,18 @@ +n = int(input()) + +# dp = 1로 만들기 위한 최소 연산 횟수 +# 가능한 연산은 3가지 +# 1. dp[i] = dp[i-1] + 1 +# 2. dp[i//2] + 1 +# 3. dp[i//3] + 1 +# 근데 나눠지는지 미리 체크해줘야됨 + +dp = [0] * (n + 1) +for i in range(2, n + 1): + dp[i] = dp[i - 1] + 1 + if i % 2 == 0: + dp[i] = min(dp[i], dp[i // 2] + 1) + if i % 3 == 0: + dp[i] = min(dp[i], dp[i // 3] + 1) + +print(dp[n]) \ No newline at end of file diff --git "a/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\213\254\355\214\275\354\235\264.py" "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\213\254\355\214\275\354\235\264.py" new file mode 100644 index 0000000..90a7761 --- /dev/null +++ "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\213\254\355\214\275\354\235\264.py" @@ -0,0 +1,38 @@ +n = int(input()) +target = int(input()) + +# 상 우 하 좌 +dx = [-1, 0, 1, 0] +dy = [0, 1, 0, -1] +ii = 0 + +arr = [[0 for _ in range(n)] for _ in range(n)] +i, j = n // 2, n // 2 + +cur_num = 1 +arr[i][j] = cur_num +count, turn, flag = 1, 1, 0 +ans = [] +while cur_num <= n ** 2: + if cur_num == target: + ans = [i + 1,j + 1] + + arr[i][j] = cur_num + i, j = i + dx[ii], j + dy[ii] + + if count == turn: + if flag == 1: + turn += 1 + flag = 0 + else: + flag = 1 + count = 0 + ii = (ii + 1) % 4 + + count += 1 + cur_num += 1 + +for i in range(n): + print(' '.join(map(str, arr[i]))) + +print(ans[0], ans[1]) \ No newline at end of file diff --git "a/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\221\220 \354\212\244\355\213\260\354\273\244.py" "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\221\220 \354\212\244\355\213\260\354\273\244.py" new file mode 100644 index 0000000..49a1928 --- /dev/null +++ "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\221\220 \354\212\244\355\213\260\354\273\244.py" @@ -0,0 +1,27 @@ +from itertools import combinations + +H, W = map(int, input().split()) +N = int(input()) +stickers = [tuple(map(int, input().split())) for _ in range(N)] + +max_size = 0 + +for comb in combinations(stickers, 2): + sticker1, sticker2 = comb + # 스티커1 회전: (h1, w1), (w1, h1) + s1_variants = [sticker1, (sticker1[1], sticker1[0])] + # 스티커2 회전: (h2, w2), (w2, h2) + s2_variants = [sticker2, (sticker2[1], sticker2[0])] + + for s1 in s1_variants: + for s2 in s2_variants: + h1, w1 = s1 + h2, w2 = s2 + # 수평 배치 + if max(h1, h2) <= H and w1 + w2 <= W: + max_size = max(max_size, h1 * w1 + h2 * w2) + # 수직 배치 + if max(w1, w2) <= W and h1 + h2 <= H: + max_size = max(max_size, h1 * w1 + h2 * w2) + +print(max_size) \ No newline at end of file diff --git "a/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..d5cdb9f --- /dev/null +++ "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,28 @@ +from collections import deque, defaultdict + +N = int(input()) +M = int(input()) +edges = [tuple(map(int, input().split())) for _ in range(M)] + +neighbors = defaultdict(list) +for edge in edges: + a, b = edge + neighbors[a].append(b) + neighbors[b].append(a) + + +# bfs +queue = deque([1]) +visited = set() +visited.add(1) +count = 0 + +while queue: + node = queue.popleft() + for neighbor in neighbors[node]: + if neighbor not in visited and neighbor not in queue: + queue.append(neighbor) + visited.add(neighbor) + count += 1 + +print(count) diff --git "a/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\354\204\234\352\260\225\352\267\274\354\234\241\353\247\250.py" "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\354\204\234\352\260\225\352\267\274\354\234\241\353\247\250.py" new file mode 100644 index 0000000..4b3d1f8 --- /dev/null +++ "b/1\354\243\274\354\260\250_\352\270\260\354\236\254\355\230\204/\354\204\234\352\260\225\352\267\274\354\234\241\353\247\250.py" @@ -0,0 +1,17 @@ +N = int(input()) +nums = list(map(int, input().split())) + +nums.sort() +ans = 0 + +# 홀수일때는 미리 하나 뺌 +if N % 2 == 1: + ans = nums[-1] + nums = nums[:-1] + N -= 1 + +# 근손실의 최적의 경우의 수의 최댓값 +for i in range(N // 2): + ans = max(ans, nums[i] + nums[N - 1 - i]) + +print(ans) \ No newline at end of file