diff --git "a/live8/test90/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" "b/live8/test90/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..6737e6e5 --- /dev/null +++ "b/live8/test90/\353\254\270\354\240\2341/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,30 @@ +def main(): + n = int(input()) + + array = list(map(int, input().strip().split()))[:n] + + x = int(input()) + + array.sort() + + count = 0 + left, right = 0, n - 1 + + while left < right: + sum = array[left] + array[right] + + if sum == x: + count += 1 + left += 1 + right -= 1 + elif sum < x: + left += 1 + else: + right -= 1 + + + print(count) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git "a/live8/test90/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" "b/live8/test90/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..69c60906 --- /dev/null +++ "b/live8/test90/\353\254\270\354\240\2342/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,27 @@ +from itertools import * + + +def main(): + + # 백트래킹을 이용한 방법 + N, M = map(int, input().split()) + + def backtrack(start, sequence): + if len(sequence) == M: + print(' '.join(map(str, sequence))) + return + + for i in range(start, N+1): + backtrack(i+1, sequence+[i]) + + backtrack(1, []) + + # combinations를 이용한 방법 + N, M = map(int, input().split()) + + for c in combinations(range(1, N+1), M): + print(' '.join(map(str, c))) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git "a/live8/test90/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" "b/live8/test90/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" new file mode 100644 index 00000000..0ac15efd --- /dev/null +++ "b/live8/test90/\353\254\270\354\240\2343/\353\260\261\355\225\234\352\262\260.py" @@ -0,0 +1,17 @@ +def solution(n, computers): + visited = [False] * n + + def dfs(v): + visited[v] = True + for i in range(n): + if computers[v][i] == 1 and not visited[i]: + dfs(i) + + count = 0 + + for i in range(n): + if not visited[i]: + dfs(i) + count += 1 + + return count \ No newline at end of file