diff --git a/src/main/kotlin/jimin/44week/CCW.py b/src/main/kotlin/jimin/44week/CCW.py new file mode 100644 index 00000000..e02f63b9 --- /dev/null +++ b/src/main/kotlin/jimin/44week/CCW.py @@ -0,0 +1,19 @@ +''' +1도 모르겠습니다. +수학 다 까먹었습니다.. +https://growth-coder.tistory.com/163 +''' + +p1_x, p1_y = map(int, input().split()) +p2_x, p2_y = map(int, input().split()) +p3_x, p3_y = map(int, input().split()) + +res = p1_x * p2_y + p2_x * p3_y + p3_x * p1_y - (p2_x * p1_y + p3_x * p2_y + p1_x * p3_y) + +if res > 0: + print(1) +elif res < 0: + print(-1) +else: + print(0) + diff --git "a/src/main/kotlin/jimin/44week/\354\240\204\352\265\254\354\231\200 \354\212\244\354\234\204\354\271\230.py" "b/src/main/kotlin/jimin/44week/\354\240\204\352\265\254\354\231\200 \354\212\244\354\234\204\354\271\230.py" new file mode 100644 index 00000000..04cf2531 --- /dev/null +++ "b/src/main/kotlin/jimin/44week/\354\240\204\352\265\254\354\231\200 \354\212\244\354\234\204\354\271\230.py" @@ -0,0 +1,42 @@ +''' +https://astrid-dm.tistory.com/429 +첫번째 전구를 누르고 시작하는 경우, +첫번째 전구를 누르지 않고 시작하는 경우 +2가지를 구해서 적은 횟수로 출력! +''' + +n = int(input()) +before = list(map(int, list(input()))) +after = list(map(int, list(input()))) + +# 첫번째 전구 안누름 +now_1 = before[:] +num_1 = 0 +for i in range(0, n - 1): + if now_1[i] != after[i]: + num_1 += 1 + now_1[i] = 1 - now_1[i] + now_1[i + 1] = 1 - now_1[i + 1] + if i + 2 < n: + now_1[i + 2] = 1 - now_1[i + 2] + +now_2 = before[:] +now_2[0] = not now_2[0] +now_2[1] = not now_2[1] +num_2 = 1 +for i in range(0, n - 1): + if now_2[i] != after[i]: + num_2 += 1 + now_2[i] = 1 - now_2[i] + now_2[i + 1] = 1 - now_2[i + 1] + if i + 2 < n: + now_2[i + 2] = 1 - now_2[i + 2] + +if now_1 != after and now_2 == after: + print(num_2) +elif now_2 != after and now_1 == after: + print(num_1) +elif now_1 == after and now_2 == after: + print(min(num_1, num_2)) +else: + print(-1) diff --git "a/src/main/kotlin/jimin/44week/\354\274\200\353\271\210 \353\262\240\354\235\264\354\273\250\354\235\230 6\353\213\250\352\263\204 \353\262\225\354\271\231.py" "b/src/main/kotlin/jimin/44week/\354\274\200\353\271\210 \353\262\240\354\235\264\354\273\250\354\235\230 6\353\213\250\352\263\204 \353\262\225\354\271\231.py" new file mode 100644 index 00000000..3b3f4a05 --- /dev/null +++ "b/src/main/kotlin/jimin/44week/\354\274\200\353\271\210 \353\262\240\354\235\264\354\273\250\354\235\230 6\353\213\250\352\263\204 \353\262\225\354\271\231.py" @@ -0,0 +1,34 @@ +from collections import defaultdict +from collections import deque + +def getBaconNum(n): + global bacons + q = deque([n]) + visited = [0 for _ in range(len(bacons) + 1)] + num = 1 + while q: + now = q.popleft() + for i in bacons[now]: + if visited[i] == 0 and i != n: + visited[i] = visited[now] + 1 + q.append(i) + num += 1 + return sum(visited) + + +n, m = map(int, input().split()) +bacons = defaultdict(list) + +for i in range(m): + a, b = map(int, input().split()) + bacons[a].append(b) + bacons[b].append(a) + +mini = 500001 +result = 0 +for i in range(1, n + 1): + num = getBaconNum(i) + if mini > num: + result = i + mini = num +print(result) \ No newline at end of file diff --git "a/src/main/kotlin/jimin/44week/\355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.py" "b/src/main/kotlin/jimin/44week/\355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.py" new file mode 100644 index 00000000..b8286ec9 --- /dev/null +++ "b/src/main/kotlin/jimin/44week/\355\225\250\352\273\230 \353\270\224\353\241\235 \354\214\223\352\270\260.py" @@ -0,0 +1,21 @@ +''' +https://magentino.tistory.com/234 +이해안감 +''' + +n, m, h = map(int, input().split()) +students = [] +for i in range(n): + students.append([0] + list(map(int, input().split()))) + +dp = [[0 for _ in range(h + 1)] for _ in range(n + 1)] +dp[0][0] = 1 + +for i in range(n): + for j in range(h + 1): + if dp[i][j]: + for s in students[i]: + if j + s <= h: + dp[i + 1][j + s] = (dp[i + 1][j + s] + dp[i][j]) % 10007 + +print(dp[-1][-1]) \ No newline at end of file