From 5c7d26ed1fc5ace0536bdcfdba3ac92611f4df9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=A7=84?= Date: Wed, 23 Apr 2025 15:21:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[#53]=2016953=20A=E2=86=92B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "eunjin_kim/graph/16953_A\342\206\222B_S2.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "eunjin_kim/graph/16953_A\342\206\222B_S2.py" diff --git "a/eunjin_kim/graph/16953_A\342\206\222B_S2.py" "b/eunjin_kim/graph/16953_A\342\206\222B_S2.py" new file mode 100644 index 0000000..0547fef --- /dev/null +++ "b/eunjin_kim/graph/16953_A\342\206\222B_S2.py" @@ -0,0 +1,33 @@ +''' +[1]알고리즘, 최악복잡도 +bfs 연산의 최솟값을 구하는 문제이므로 dfsXX +[2]경계값, 히든테케 +- -1 출력 +- 1,000,000,000 < 2^30 -> int 정수최댓값 2^32-1 -> ok +[3]슈도코드 +''' + +import sys +from collections import deque +input = sys.stdin.readline + +def bfs(start): + q = deque([(start, 1)]) + + while q: + x, cnt = q.popleft() + y, z = x * 2, int(str(x) + '1') + cnt += 1 + + if y == target or z == target: + return cnt + if y < target: + q.append((y, cnt)) + if z < target: + q.append((z, cnt)) + + return -1 + + +n, target = map(int, input().split()) +print(bfs(n)) \ No newline at end of file From e305e97fed3f517261d3051b2f2395c4986bbe56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=A7=84?= Date: Wed, 23 Apr 2025 17:52:05 +0900 Subject: [PATCH 2/3] [#54] 17626 Four Squares --- eunjin_kim/dp/17626_Four Squares_S3.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 eunjin_kim/dp/17626_Four Squares_S3.py diff --git a/eunjin_kim/dp/17626_Four Squares_S3.py b/eunjin_kim/dp/17626_Four Squares_S3.py new file mode 100644 index 0000000..662ea0c --- /dev/null +++ b/eunjin_kim/dp/17626_Four Squares_S3.py @@ -0,0 +1,26 @@ +''' +17626_Four Squares_S3 #54 +pypy3 제출 + +[1]알고리즘, 최악복잡도 +DP +''' + +import sys +sys.stdin = open("제출전삭제.txt","rt") +input = sys.stdin.readline + +n = int(input()) +dp = [4] * (n+1) + +for x in range(1, n+1): + if x ** 2 <= n: + dp[x**2] = 1 + + if dp[x] == 1: + continue + + for y in range(int(x ** 0.5), 0, -1): + dp[x] = min(dp[x], dp[y**2] + dp[x - y**2]) + +print(dp[n]) \ No newline at end of file From 0cbad2fa13c3972378f5744cfbdd0f4f49ff1c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=A7=84?= Date: Wed, 23 Apr 2025 17:58:18 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[#57]=2014501=20=ED=87=B4=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14501_\355\207\264\354\202\254_S3.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "eunjin_kim/brute_force/14501_\355\207\264\354\202\254_S3.py" diff --git "a/eunjin_kim/brute_force/14501_\355\207\264\354\202\254_S3.py" "b/eunjin_kim/brute_force/14501_\355\207\264\354\202\254_S3.py" new file mode 100644 index 0000000..f79b6a4 --- /dev/null +++ "b/eunjin_kim/brute_force/14501_\355\207\264\354\202\254_S3.py" @@ -0,0 +1,33 @@ +''' +14501_퇴사_S3 #57 + +[1]알고리즘, 최악복잡도 +완탐 +[2]경계값, 히든테케 +[3]슈도코드 +''' + +import sys +input = sys.stdin.readline + + +def dfs(depth, price): + global max_price + if depth == n: + max_price = max(max_price, price) + return + + if depth > n: + return + + t, p = seq[depth] + dfs(depth + t, price + p) + dfs(depth + 1, price) + + +n = int(input()) +seq = [list(map(int, input().split())) for _ in range(n)] + +max_price = 0 +dfs(0, 0) +print(max_price) \ No newline at end of file