diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 20f033c..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 391f202..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 90d5e90..113f143 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ - + - + @@ -16,7 +16,7 @@ - + @@ -37,6 +37,7 @@ + @@ -46,6 +47,7 @@ uoo6uoow + @@ -53,6 +55,7 @@ ity0526 +
진행 기간2023년 6월 28일 ~ 2024년 6월 28일 ~ 2025년 1월 12일
스터디 장소오프라인온라인
정기 스터디 시간
플랫폼백준백준, 프로그래머스
언어
oyatplum ity0526 jungyungeejay91537
diff --git a/ity0562/.DS_Store b/ity0562/.DS_Store new file mode 100644 index 0000000..84794fd Binary files /dev/null and b/ity0562/.DS_Store differ diff --git a/ity0562/ity0526_week1/.DS_Store b/ity0562/ity0526_week1/.DS_Store new file mode 100644 index 0000000..2a49905 Binary files /dev/null and b/ity0562/ity0526_week1/.DS_Store differ diff --git "a/ity0562/ity0526_week1/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" "b/ity0562/ity0526_week1/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" new file mode 100644 index 0000000..eaa9c4b --- /dev/null +++ "b/ity0562/ity0526_week1/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" @@ -0,0 +1,15 @@ +N = input() +count = 0; +i = 666 + +while(True) : + iStr = str(i) + + if("666" in iStr) : + count += 1 + if(count == int(N)) : + break + + i += 1 + +print(i); \ No newline at end of file diff --git "a/ity0562/ity0526_week10/\352\264\204\355\230\270.py" "b/ity0562/ity0526_week10/\352\264\204\355\230\270.py" new file mode 100644 index 0000000..298f86b --- /dev/null +++ "b/ity0562/ity0526_week10/\352\264\204\355\230\270.py" @@ -0,0 +1,37 @@ +num = int(input()) + +while num != 0: + line = input() + lineList = list(line) + parenList = [] + isValid = True + + for i in lineList: + if i == '(': + parenList.append(i) + elif i == '[' : + parenList.append(i) + elif i == ')' : + if not parenList : + isValid = False + break + elif parenList[-1] == '[' : + isValid = False + break + parenList.pop() + elif i == ']' : + if not parenList: + isValid = False + break + elif parenList[-1] == '(': + isValid = False + break + parenList.pop() + + if not parenList and isValid: + print("YES") + else : + print("NO") + + num -= 1 + diff --git "a/ity0562/ity0526_week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" "b/ity0562/ity0526_week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" new file mode 100644 index 0000000..6964e0e --- /dev/null +++ "b/ity0562/ity0526_week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" @@ -0,0 +1,35 @@ +line = input() + +while line != '.': + parenList = [] + lineList = list(line) + isValid = True + for i in lineList: + if i == '(': + parenList.append(i) + elif i == '[' : + parenList.append(i) + elif i == ')' : + if not parenList : + isValid = False + break + elif parenList[-1] == '[' : + isValid = False + break + parenList.pop() + elif i == ']' : + if not parenList: + isValid = False + break + elif parenList[-1] == '(': + isValid = False + break + parenList.pop() + + if not parenList and isValid: + print("yes") + else : + print("no") + + + line = input() diff --git "a/ity0562/ity0526_week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" "b/ity0562/ity0526_week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" new file mode 100644 index 0000000..52d3546 --- /dev/null +++ "b/ity0562/ity0526_week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" @@ -0,0 +1,11 @@ +A, B, V = map(int, input().split()) +H = 0 + +day = (V-A)//(A-B) + +if (V-A)%(A-B) == 0 : + day += 1 +else: + day += 2 + +print(day) \ No newline at end of file diff --git "a/ity0562/ity0526_week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/ity0562/ity0526_week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..79f9ba8 --- /dev/null +++ "b/ity0562/ity0526_week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,13 @@ +import sys + +N = int(sys.stdin.readline()) + +numList = [0] * 10000 + +for i in range(N): + numList[int(sys.stdin.readline())-1] += 1 + +for i in range(10000): + if numList[i] != 0: + for j in range(numList[i]): + print(i+1) \ No newline at end of file diff --git "a/ity0562/ity0526_week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" "b/ity0562/ity0526_week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" new file mode 100644 index 0000000..6c19f6c --- /dev/null +++ "b/ity0562/ity0526_week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" @@ -0,0 +1,21 @@ +import sys + +N = int(sys.stdin.readline()) +NList = list(map(int, sys.stdin.readline().split())) + +M = int(sys.stdin.readline()) +MList = list(map(int, sys.stdin.readline().split())) + +count = {} +for i in NList: + if i in count: + count[i] += 1 + else: + count[i] = 1 + +for i in MList: + if i in count: + print(count[i], end=" ") + else : + print(0, end=" ") + diff --git "a/ity0562/ity0526_week11/\354\240\234\353\241\234.py" "b/ity0562/ity0526_week11/\354\240\234\353\241\234.py" new file mode 100644 index 0000000..cf7add7 --- /dev/null +++ "b/ity0562/ity0526_week11/\354\240\234\353\241\234.py" @@ -0,0 +1,18 @@ +from itertools import count + +K = int(input()) +numList = [] +for _ in range(K): + N = int(input()) + + if N == 0 : + try : + numList.pop() + except IndexError: + continue + else : + numList.append(N) + +listSum = sum(numList) + +print(listSum) \ No newline at end of file diff --git "a/ity0562/ity0526_week12/\354\212\244\355\203\235.py" "b/ity0562/ity0526_week12/\354\212\244\355\203\235.py" new file mode 100644 index 0000000..6f8ffc5 --- /dev/null +++ "b/ity0562/ity0526_week12/\354\212\244\355\203\235.py" @@ -0,0 +1,20 @@ +import sys + +N = int(sys.stdin.readline()) +stack = [] + +for _ in range(N): + command = sys.stdin.readline().split() + if command[0] == "push" : + stack.append(command[1]) + elif command[0] == "pop" : + if not stack : print(-1) + else : print(stack.pop()) + elif command[0] == "size" : + print(len(stack)) + elif command[0] == "empty" : + if stack : print(0) + else : print(1) + elif command[0] == "top" : + if stack : print(stack[-1]) + else : print(-1) diff --git "a/ity0562/ity0526_week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" "b/ity0562/ity0526_week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" new file mode 100644 index 0000000..acd1ef7 --- /dev/null +++ "b/ity0562/ity0526_week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" @@ -0,0 +1,11 @@ +N, K = map(int, input().split()) +num1 = 1 +num2 = 1 + +for i in range(K) : + num1 *= N + N -= 1 +for j in range(1, K+1) : + num2 *= j + +print(num1//num2) diff --git "a/ity0562/ity0526_week12/\355\201\220.py" "b/ity0562/ity0526_week12/\355\201\220.py" new file mode 100644 index 0000000..b5ec24e --- /dev/null +++ "b/ity0562/ity0526_week12/\355\201\220.py" @@ -0,0 +1,23 @@ +import sys + +N = int(sys.stdin.readline()) +queue = [] + +for _ in range(N): + command = sys.stdin.readline().split() + if command[0] == "push" : + queue.append(command[1]) + elif command[0] == "pop" : + if not queue : print(-1) + else : print(queue.pop(0)) + elif command[0] == "size" : + print(len(queue)) + elif command[0] == "empty" : + if queue : print(0) + else : print(1) + elif command[0] == "front" : + if queue : print(queue[0]) + else : print(-1) + elif command[0] == "back" : + if queue : print(queue[-1]) + else : print(-1) diff --git a/ity0562/ity0526_week13/FizzBuzz.py b/ity0562/ity0526_week13/FizzBuzz.py new file mode 100644 index 0000000..cd3fb8e --- /dev/null +++ b/ity0562/ity0526_week13/FizzBuzz.py @@ -0,0 +1,15 @@ +import sys + +for i in range(3, 0, -1): + string = sys.stdin.readline().strip() + if string not in ['Fizz', 'Buzz', 'FizzBuzz']: + n = int(string) + i + +if n%3==0 and n%5==0: + print('FizzBuzz') +elif n%3==0: + print('Fizz') +elif n%5==0: + print('Buzz') +else: + print(n) \ No newline at end of file diff --git a/ity0562/ity0526_week13/solved.ac.py b/ity0562/ity0526_week13/solved.ac.py new file mode 100644 index 0000000..a311237 --- /dev/null +++ b/ity0562/ity0526_week13/solved.ac.py @@ -0,0 +1,26 @@ +import sys +import statistics + +def roundNum(a) : + if a - int(a) >= 0.5 : + return int(a) + 1 + else : + return int(a) + +N = int(sys.stdin.readline()) + +if N == 0 : + print(0) + +else : + trimN = roundNum(N * 0.15) + + numList = [int(sys.stdin.readline().strip()) for _ in range(N)] + numList.sort() + trimList = numList[trimN: N - trimN] + + print(roundNum(statistics.mean(trimList))) + + + + diff --git "a/ity0562/ity0526_week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" "b/ity0562/ity0526_week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..0611c25 --- /dev/null +++ "b/ity0562/ity0526_week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" @@ -0,0 +1,10 @@ +N, M = map(int, input().split()) + +for i in range(N, M + 1): + if i == 1 : + continue + for j in range(2, int(i ** 0.5) + 1) : + if i % j == 0 : + break + else : + print(i) \ No newline at end of file diff --git "a/ity0562/ity0526_week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/ity0562/ity0526_week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..30e049c --- /dev/null +++ "b/ity0562/ity0526_week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,22 @@ +import sys + +K, N = map(int, sys.stdin.readline().split()) +num_list = list() +for _ in range(K): + num_list.append(int(sys.stdin.readline())) + +start = 1 +end = max(num_list) + +while start <= end : + mid = (start + end) // 2 + line_count = 0 + for i in num_list: + line_count += i//mid + + if line_count >= N: + start = mid + 1 + else: + end = mid - 1 + +print(end) \ No newline at end of file diff --git "a/ity0562/ity0526_week14/\355\206\265\352\263\204\355\225\231.py" "b/ity0562/ity0526_week14/\355\206\265\352\263\204\355\225\231.py" new file mode 100644 index 0000000..ba694bf --- /dev/null +++ "b/ity0562/ity0526_week14/\355\206\265\352\263\204\355\225\231.py" @@ -0,0 +1,33 @@ +import sys + +N = int(sys.stdin.readline()) +num_list = [] +num_count = {} + +for _ in range(N): + num = int(sys.stdin.readline()) + num_list.append(num) + + if num not in num_count: + num_count[num] = 1 + else: + num_count[num] += 1 + +num_list.sort() + +print(round(sum(num_list) / len(num_list))) + +print(num_list[N//2]) + +freq = max(num_count.values()) +num_freq = [] +for k, v in num_count.items(): + if v == freq: + num_freq.append(k) + +if len(num_freq) > 1: + print(sorted(num_freq)[1]) +else : + print(num_freq[0]) + +print(num_list[-1] - num_list[0]) diff --git "a/ity0562/ity0526_week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/ity0562/ity0526_week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..2d731ed --- /dev/null +++ "b/ity0562/ity0526_week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,30 @@ +import sys + +C = int(sys.stdin.readline()) + +for _ in range(C) : + N, M = map(int, sys.stdin.readline().split()) + doc_list = list(map(int, sys.stdin.readline().split())) + + result = 0 + while doc_list : + if doc_list[0] < max(doc_list) : + doc_list.append(doc_list[0]) + doc_list.pop(0) + + if M == 0 : + M = len(doc_list) - 1 + else : + M -= 1 + + else : + if M == 0 : + result += 1 + break + + doc_list.pop(0) + M -= 1 + result += 1 + + print(result) + diff --git "a/ity0562/ity0526_week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" "b/ity0562/ity0526_week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" new file mode 100644 index 0000000..c65087f --- /dev/null +++ "b/ity0562/ity0526_week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" @@ -0,0 +1,18 @@ +import sys + +N, M = map(int, sys.stdin.readline().split()) +p_list = [0] +p_dict = {} + +for i in range(1, N+1): + name = sys.stdin.readline().strip() + p_list.append(name) + p_dict[name] = i + +for _ in range(M): + Q = sys.stdin.readline().strip() + if Q.isdigit() : + print(p_list[int(Q)]) + else : + print(p_dict[Q]) + diff --git "a/ity0562/ity0526_week15/\353\223\243\353\263\264\354\236\241.py" "b/ity0562/ity0526_week15/\353\223\243\353\263\264\354\236\241.py" new file mode 100644 index 0000000..a923460 --- /dev/null +++ "b/ity0562/ity0526_week15/\353\223\243\353\263\264\354\236\241.py" @@ -0,0 +1,17 @@ +import sys + +N, M = map(int, sys.stdin.readline().split()) +nl_list = [] +ns_list = [] + +for _ in range(N): + nl_list.append(sys.stdin.readline().strip()) + +for _ in range(M): + ns_list.append(sys.stdin.readline().strip()) + +nls_set = set(nl_list) & set(ns_list) +print(len(nls_set)) + +for i in sorted(nls_set): + print(i) \ No newline at end of file diff --git "a/ity0562/ity0526_week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" "b/ity0562/ity0526_week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" new file mode 100644 index 0000000..856ab5d --- /dev/null +++ "b/ity0562/ity0526_week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" @@ -0,0 +1,38 @@ +import sys + +N = int(sys.stdin.readline()) +push = 0 +pop = 0 +num_stack = [] +op_stack = [] +cor = 1 + +for _ in range(N): + num = int(sys.stdin.readline()) + if num >= push : + for _ in range(num - push): + push += 1 + num_stack.append(push) + op_stack.append('+') + pop = num + num_stack.pop() + op_stack.append('-') + + else : + try : + if num < pop: + for _ in range(len(num_stack) - num_stack.index(num)) : + num_stack.pop() + op_stack.append('-') + pop = num + + else : + cor = 0 + except ValueError : + cor = 0 + +if cor == 0: + print("NO") +else : + for i in op_stack: + print(i) diff --git "a/ity0562/ity0526_week15/\354\247\221\355\225\251.py" "b/ity0562/ity0526_week15/\354\247\221\355\225\251.py" new file mode 100644 index 0000000..f4552ef --- /dev/null +++ "b/ity0562/ity0526_week15/\354\247\221\355\225\251.py" @@ -0,0 +1,33 @@ +import sys + +N = int(sys.stdin.readline()) + +num_list = [0]*21 + +for _ in range(N): + parts = sys.stdin.readline().split() + op = parts[0] + + if op == 'add': + num = int(parts[1]) + num_list[num] = 1 + elif op == 'remove': + num = int(parts[1]) + num_list[num] = 0 + elif op == 'check' : + num = int(parts[1]) + if num_list[num] == 0: + print(0) + else : + print(1) + elif op == 'toggle': + num = int(parts[1]) + if num_list[num] == 0: + num_list[num] = 1 + else: + num_list[num] = 0 + elif op == 'all': + num_list = [1]*21 + else : + num_list = [0]*21 + diff --git "a/ity0562/ity0526_week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" "b/ity0562/ity0526_week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..afa6470 --- /dev/null +++ "b/ity0562/ity0526_week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" @@ -0,0 +1,16 @@ +def make_one(n): + 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) + + return dp[n] + +n = int(input()) +print(make_one(n)) \ No newline at end of file diff --git "a/ity0562/ity0526_week16/DFS\354\231\200 BFS.py" "b/ity0562/ity0526_week16/DFS\354\231\200 BFS.py" new file mode 100644 index 0000000..a949f47 --- /dev/null +++ "b/ity0562/ity0526_week16/DFS\354\231\200 BFS.py" @@ -0,0 +1,41 @@ +from collections import defaultdict, deque +import sys + +def dfs(graph, start, visited): + visited[start] = True + print(start, end=' ') + + for neighbor in sorted(graph[start]): + if not visited[neighbor]: + dfs(graph, neighbor, visited) + +def bfs(graph, start): + visited = [False] * len(graph) + queue = deque([start]) + visited[start] = True + + while queue: + current = queue.popleft() + print(current, end=' ') + + for neighbor in sorted(graph[current]): + if not visited[neighbor]: + visited[neighbor] = True + queue.append(neighbor) + + +N, M, V = map(int, sys.stdin.readline().split()) +graph = [[] for _ in range(N+1)] +visited = [False] * (N+1) + +for _ in range(M): + v1, v2 = map(int, sys.stdin.readline().split()) + graph[v1].append(v2) + graph[v2].append(v1) + +dfs(graph, V, visited) +print() + +bfs(graph, V) +print() + diff --git "a/ity0562/ity0526_week16/\353\217\231\354\240\204 0.py" "b/ity0562/ity0526_week16/\353\217\231\354\240\204 0.py" new file mode 100644 index 0000000..e18930e --- /dev/null +++ "b/ity0562/ity0526_week16/\353\217\231\354\240\204 0.py" @@ -0,0 +1,13 @@ +import sys + +N, K = map(int, sys.stdin.readline().split()) +count = 0 +coin_list = [] +for _ in range(N) : + coin_list.append(int(sys.stdin.readline())) + +for i in reversed(coin_list) : + count += K // i + K %= i + +print(count) \ No newline at end of file diff --git "a/ity0562/ity0526_week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" "b/ity0562/ity0526_week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" new file mode 100644 index 0000000..662f0a2 --- /dev/null +++ "b/ity0562/ity0526_week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" @@ -0,0 +1,24 @@ +import sys + +zero_list = [0] * 41 +one_list = [0] * 41 + +zero_list[0] = 1 +one_list[1] = 1 + +T = int(sys.stdin.readline()) + +for _ in range(T): + N = int(sys.stdin.readline()) + if N == 0 : + print(1, 0) + elif N == 1: + print(0, 1) + else: + for i in range(2, N+1) : + zero_list[i] = zero_list[i-1] + zero_list[i-2] + one_list[i] = one_list[i-1] + one_list[i-2] + + print(zero_list[N], one_list[N]) + + diff --git a/ity0562/ity0526_week17/ATM.py b/ity0562/ity0526_week17/ATM.py new file mode 100644 index 0000000..4f81edc --- /dev/null +++ b/ity0562/ity0526_week17/ATM.py @@ -0,0 +1,13 @@ +import sys + +N = int(sys.stdin.readline()) +P = list(map(int, sys.stdin.readline().split())) + +P.sort() +time = 0 +sum = 0 +for i in P : + time = time + i + sum = sum + time + +print(sum) diff --git "a/ity0562/ity0526_week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/ity0562/ity0526_week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..687b407 --- /dev/null +++ "b/ity0562/ity0526_week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,17 @@ +import sys + +N = int(sys.stdin.readline()) +scores = [0] + [int(sys.stdin.readline()) for _ in range(N)] + +dp = [0] * (N+1) + +dp[1] = scores[1] +if N > 1: + dp[2] = scores[1] + scores[2] +if N > 2: + dp[3] = max(scores[1] + scores[3], scores[2] + scores[3]) + +for i in range(4, N + 1): + dp[i] = max(dp[i-2] + scores[i], dp[i-3] + scores[i-1] + scores[i]) + +print(dp[N]) \ No newline at end of file diff --git "a/ity0562/ity0526_week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/ity0562/ity0526_week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..954b3e8 --- /dev/null +++ "b/ity0562/ity0526_week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,22 @@ +import sys + +def dfs(graph, start, visited): + visited[start] = True + count = 1 + for neighbor in sorted(graph[start]): + if not visited[neighbor]: + count += dfs(graph, neighbor, visited) + return count + +N = int(sys.stdin.readline()) +M = int(sys.stdin.readline()) + +graph = [[] for _ in range(N+1)] +for _ in range(M): + a, b = map(int, sys.stdin.readline().split()) + graph[a].append(b) + graph[b].append(a) + +visited = [False for _ in range(N+1)] +result = dfs(graph, 1, visited) - 1 +print(result) \ No newline at end of file diff --git "a/ity0562/ity0526_week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" "b/ity0562/ity0526_week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" new file mode 100644 index 0000000..fbec96e --- /dev/null +++ "b/ity0562/ity0526_week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" @@ -0,0 +1,30 @@ +def dfs(x, y, graph, visited, n, m): + directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] + visited[x][y] = True + + for dx, dy in directions: + nx, ny = x + dx, y + dy + if 0 <= nx < n and 0 <= ny < m and not visited[nx][ny] and graph[nx][ny] == 1: + dfs(nx, ny, graph, visited, n, m) + + +t = int(input()) + +for _ in range(t): + m, n, k = map(int, input().split()) + graph = [[0] * m for _ in range(n)] + visited = [[False] * m for _ in range(n)] + + for _ in range(k): + x, y = map(int, input().split()) + graph[y][x] = 1 + + worm_count = 0 + + for i in range(n): + for j in range(m): + if graph[i][j] == 1 and not visited[i][j]: + dfs(i, j, graph, visited, n, m) + worm_count += 1 + + print(worm_count) \ No newline at end of file diff --git "a/uoo6uoow/Week1/\354\230\201\355\231\224\352\260\220\353\217\205" "b/ity0562/ity0526_week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.py" similarity index 100% rename from "uoo6uoow/Week1/\354\230\201\355\231\224\352\260\220\353\217\205" rename to "ity0562/ity0526_week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.py" diff --git "a/ity0562/ity0526_week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" "b/ity0562/ity0526_week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..40c8e60 --- /dev/null +++ "b/ity0562/ity0526_week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,9 @@ +def solution(numbers): + answer_set = set() + for i in range(len(numbers)): + for j in range(i+1, len(numbers)) : + answer_set.add(numbers[i]+numbers[j]) + + answer = list(answer_set) + answer.sort() + return answer \ No newline at end of file diff --git "a/ity0562/ity0526_week18/\354\202\274\352\260\201\353\213\254\355\214\275\354\235\264.py" "b/ity0562/ity0526_week18/\354\202\274\352\260\201\353\213\254\355\214\275\354\235\264.py" new file mode 100644 index 0000000..cd41d81 --- /dev/null +++ "b/ity0562/ity0526_week18/\354\202\274\352\260\201\353\213\254\355\214\275\354\235\264.py" @@ -0,0 +1,26 @@ +def solution(n): + triangle = [[0] * n for _ in range(n)] + answer = [] + x, y = -1, 0 + num = 1 + + for i in range(n): + for _ in range(n - i): + + if i % 3 == 0: + x += 1 + elif i % 3 == 1: + y += 1 + + elif i % 3 == 2: + x -= 1 + y -= 1 + + triangle[x][y] = num + num += 1 + + for i in range(n): + for j in range(i + 1): + answer.append(triangle[i][j]) + + return answer \ No newline at end of file diff --git "a/ity0562/ity0526_week18/\354\265\234\354\206\214 \355\236\231.py" "b/ity0562/ity0526_week18/\354\265\234\354\206\214 \355\236\231.py" new file mode 100644 index 0000000..f96029e --- /dev/null +++ "b/ity0562/ity0526_week18/\354\265\234\354\206\214 \355\236\231.py" @@ -0,0 +1,15 @@ +import sys +import heapq + +numbers = int(sys.stdin.readline()) +heap = [] + +for _ in range(numbers): + num = int(sys.stdin.readline()) + if num != 0: + heapq.heappush(heap, num) + else: + try: + print(heapq.heappop(heap)) + except: + print(0) \ No newline at end of file diff --git "a/ity0562/ity0526_week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" "b/ity0562/ity0526_week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..79f2332 --- /dev/null +++ "b/ity0562/ity0526_week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" @@ -0,0 +1,14 @@ +import sys + +N = int(sys.stdin.readline()) +wList = [] + +for i in range(N) : + wList.append(sys.stdin.readline().strip()) + +wList = list(set(wList)) +wList.sort() +wList.sort(key = len) + +for i in wList : + print(i) diff --git "a/ity0562/ity0526_week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" "b/ity0562/ity0526_week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" new file mode 100644 index 0000000..c83ac7f --- /dev/null +++ "b/ity0562/ity0526_week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" @@ -0,0 +1,11 @@ +while True : + nList = list(map(int, input().split())) + + if nList[0]+nList[1]+nList[2] == 0 : + break; + + nList.sort(); + if nList[0]**2 + nList[1]**2 == nList[2]**2: + print("right") + else : + print("wrong") \ No newline at end of file diff --git "a/ity0562/ity0526_week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" "b/ity0562/ity0526_week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" new file mode 100644 index 0000000..b4a3591 --- /dev/null +++ "b/ity0562/ity0526_week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" @@ -0,0 +1,3 @@ +N = int(input()) + +print(int(N/5) + int(N/25) + int(N/125)) \ No newline at end of file diff --git "a/ity0562/ity0526_week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" "b/ity0562/ity0526_week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" new file mode 100644 index 0000000..b6f1ff0 --- /dev/null +++ "b/ity0562/ity0526_week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" @@ -0,0 +1,15 @@ +from collections import deque + +def solution(arr): + d = deque() + d.append(arr[0]) + for i in range(1, len(arr)): + if arr[i] != d[-1]: + d.append(arr[i]) + + answer = [] + + for i in d: + answer.append(i) + + return answer \ No newline at end of file diff --git "a/ity0562/ity0526_week20/\352\270\260\353\212\245 \352\260\234\354\204\240.py" "b/ity0562/ity0526_week20/\352\270\260\353\212\245 \352\260\234\354\204\240.py" new file mode 100644 index 0000000..a838c6c --- /dev/null +++ "b/ity0562/ity0526_week20/\352\270\260\353\212\245 \352\260\234\354\204\240.py" @@ -0,0 +1,18 @@ +def solution(progresses, speeds): + answer = [] + while progresses != []: + count = 0 + + for i in range(len(progresses)): + progresses[i] += speeds[i] + + while progresses[0:] >= [100]: + progresses.pop(0) + speeds.pop(0) + count += 1 + + if count != 0: + answer.append(count) + + + return answer \ No newline at end of file diff --git "a/ity0562/ity0526_week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" "b/ity0562/ity0526_week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" new file mode 100644 index 0000000..a6c74d4 --- /dev/null +++ "b/ity0562/ity0526_week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" @@ -0,0 +1,23 @@ +from collections import deque + + +def solution(s): + answer = True + open = deque() + + for i in s: + if i == "(": + open.append(i) + + else: + if open: + open.pop() + + else: + answer = False + break + + if open: + answer = False + + return answer \ No newline at end of file diff --git "a/ity0562/ity0526_week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" "b/ity0562/ity0526_week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" new file mode 100644 index 0000000..3abff0f --- /dev/null +++ "b/ity0562/ity0526_week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" @@ -0,0 +1,25 @@ +def solution(n, times): + a, b = 0, 100000 * 1000000000 + m = 0 + while a < b: + m = (a + b) // 2 + + if is_avalible(n, times, m): + b = m + else: + a = m + 1 + + answer = b + return answer + + +def is_avalible(n, times, m): + sum = 0 + + for i in times: + sum += m // i + + if n <= sum: + return True + else: + return False \ No newline at end of file diff --git "a/ity0562/ity0526_week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/ity0562/ity0526_week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..6056776 --- /dev/null +++ "b/ity0562/ity0526_week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,16 @@ +N = int(input()) +numList = list(map(int, input().split())) +count = 0; + +for i in range(N) : + if numList[i] == 2 : + count += 1 + + elif numList[i] > 2 : + for j in range(2, numList[i]+1) : + if numList[i] % j == 0 : + if numList[i] == j : + count += 1 + break + +print(count) \ No newline at end of file diff --git "a/ity0562/ity0526_week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" "b/ity0562/ity0526_week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" new file mode 100644 index 0000000..c3cb94c --- /dev/null +++ "b/ity0562/ity0526_week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" @@ -0,0 +1,13 @@ +import math + +N = int(input()) +sizeList = list(map(int, input().split())) +T, P = map(int, input().split()) + +TSet = 0 +for i in range(len(sizeList)) : + if sizeList[i] != 0 : + TSet += math.ceil(sizeList[i]/T) + +print(TSet) +print(N//P, N%P) \ No newline at end of file diff --git "a/ity0562/ity0526_week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" "b/ity0562/ity0526_week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" new file mode 100644 index 0000000..3444a68 --- /dev/null +++ "b/ity0562/ity0526_week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" @@ -0,0 +1,55 @@ +blackChess = """ +BWBWBWBW +WBWBWBWB +BWBWBWBW +WBWBWBWB +BWBWBWBW +WBWBWBWB +BWBWBWBW +WBWBWBWB +""" +blackChessList = [list(blackChess.strip().split('\n')[i]) for i in range(8)] + +whiteChess = """ +WBWBWBWB +BWBWBWBW +WBWBWBWB +BWBWBWBW +WBWBWBWB +BWBWBWBW +WBWBWBWB +BWBWBWBW +""" +whiteChessList = [list(whiteChess.strip().split('\n')[i]) for i in range(8)] + +N, M = map(int, input().split()) +allList = [list(input()) for _ in range(N)] + +leastCount = 64 + +Nidx = N-7 +Midx = M-7 + +for i in range(Nidx) : + for j in range(Midx) : + checkList = [row[j:j+8] for row in allList[i:i+8]] + + bCount = 0 + wCount = 0 + + for k in range(8) : + for l in range(8) : + if checkList[k][l] != blackChessList[k][l] : + bCount += 1 + if checkList[k][l] != whiteChessList[k][l] : + wCount += 1 + + if bCount <= wCount : + count = bCount + else : + count = wCount + + if count < leastCount : + leastCount = count + +print(leastCount) \ No newline at end of file diff --git "a/ity0562/ity0526_week4/\353\266\204\355\225\264\355\225\251.py" "b/ity0562/ity0526_week4/\353\266\204\355\225\264\355\225\251.py" new file mode 100644 index 0000000..d02171a --- /dev/null +++ "b/ity0562/ity0526_week4/\353\266\204\355\225\264\355\225\251.py" @@ -0,0 +1,10 @@ +num = int(input()) + +for i in range(1, num+1) : + i_sum = sum(map(int, str(i))) + if(num == i + i_sum) : + print(i) + break + + if(i == num): + print(0) \ No newline at end of file diff --git "a/ity0562/ity0526_week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" "b/ity0562/ity0526_week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" new file mode 100644 index 0000000..cf99666 --- /dev/null +++ "b/ity0562/ity0526_week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" @@ -0,0 +1,13 @@ +import sys + +N = int(sys.stdin.readline()) +num_list = [] + +for _ in range(N): + Num = int(sys.stdin.readline()) + num_list.append(Num) + +num_list.sort() + +for i in num_list : + print(i) \ No newline at end of file diff --git "a/ity0562/ity0526_week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" "b/ity0562/ity0526_week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" new file mode 100644 index 0000000..8cbba86 --- /dev/null +++ "b/ity0562/ity0526_week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" @@ -0,0 +1,9 @@ +while True : + num_list = list(input()) + if num_list[0] == '0' : + break + + if num_list == list(reversed(num_list)) : + print("yes") + else : + print("no") \ No newline at end of file diff --git "a/ity0562/ity0526_week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" "b/ity0562/ity0526_week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..db6e877 --- /dev/null +++ "b/ity0562/ity0526_week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" @@ -0,0 +1,14 @@ +import sys + +N = int(sys.stdin.readline()) +user_list = [] + +for _ in range(N): + age, name = sys.stdin.readline().split() + age = int(age) + user_list.append([age, name]) + +user_list.sort(key= lambda x:x[0]) + +for i in range(N): + print(user_list[i][0], user_list[i][1]) \ No newline at end of file diff --git "a/ity0562/ity0526_week5/\353\215\251\354\271\230.py" "b/ity0562/ity0526_week5/\353\215\251\354\271\230.py" new file mode 100644 index 0000000..237e7e5 --- /dev/null +++ "b/ity0562/ity0526_week5/\353\215\251\354\271\230.py" @@ -0,0 +1,12 @@ +n = int(input()) +people = [] + +for _ in range(n): + people.append(list(map(int, input().split()))) + +for i in people: + rank = 1 + for j in people: + if i[0]") \ No newline at end of file diff --git "a/ity0562/ity0526_week8/\354\210\230 \354\260\276\352\270\260.py" "b/ity0562/ity0526_week8/\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..92f7fec --- /dev/null +++ "b/ity0562/ity0526_week8/\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,25 @@ +N = int(input()) +A = list(map(int, input().split())) +M = int(input()) +arr = list(map(int, input().split())) +A.sort() + + +for num in arr: + lt, rt = 0, N - 1 + isExist = False + + + while lt <= rt: + mid = (lt + rt) // 2 + if num == A[mid]: + isExist = True + print(1) + break + elif num > A[mid]: + lt = mid + 1 + else: + rt = mid - 1 + + if not isExist: + print(0) \ No newline at end of file diff --git "a/ity0562/ity0526_week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" "b/ity0562/ity0526_week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" new file mode 100644 index 0000000..1141e0f --- /dev/null +++ "b/ity0562/ity0526_week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" @@ -0,0 +1,9 @@ +data = [] +for i in range(int(input())): + x, y = map(int,input().split()) + data.append((x,y)) + +data.sort(key = lambda x : (x[1], x[0])) + +for d in data: + print(d[0], d[1]) \ No newline at end of file diff --git "a/ity0562/ity0526_week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" "b/ity0562/ity0526_week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" new file mode 100644 index 0000000..93c75f0 --- /dev/null +++ "b/ity0562/ity0526_week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" @@ -0,0 +1,14 @@ +num1, num2 = map(int, input().split()) +a = max(num1, num2) +b = min(num1, num2) + +while True: + r = a % b + a = b + b = r + + if r == 0: + break + +print(a) +print(int(num1*num2/a)) \ No newline at end of file diff --git "a/ity0562/ity0526_week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" "b/ity0562/ity0526_week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" new file mode 100644 index 0000000..65187b3 --- /dev/null +++ "b/ity0562/ity0526_week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" @@ -0,0 +1,13 @@ +T = int(input()) + +for _ in range(T): + K = int(input()) + N = int(input()) + + floor = [x for x in range(1, N+1)] + + for k in range(K): + for i in range(1, N): + floor[i] += floor[i-1] + + print(floor[N-1]) diff --git "a/ity0562/ity0526_week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" "b/ity0562/ity0526_week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" new file mode 100644 index 0000000..a055506 --- /dev/null +++ "b/ity0562/ity0526_week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" @@ -0,0 +1,15 @@ +S = int(input()) + +B = 0 + +while S >= 0 : + if S % 5 == 0 : + B += S//5 + print(B) + break + + B += 1 + S -= 3 + +else : + print(-1) \ No newline at end of file diff --git "a/ity0562/ity0526_week9/\354\271\264\353\223\2342.py" "b/ity0562/ity0526_week9/\354\271\264\353\223\2342.py" new file mode 100644 index 0000000..c4720eb --- /dev/null +++ "b/ity0562/ity0526_week9/\354\271\264\353\223\2342.py" @@ -0,0 +1,11 @@ +input = int(input()) +square = 2 + +while True: + if (input == 1 or input == 2): + print(input) + break + square *= 2 + if (square >= input): + print((input - (square // 2)) * 2) + break \ No newline at end of file diff --git "a/jay91537/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.java" "b/jay91537/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.java" new file mode 100644 index 0000000..d9b3778 --- /dev/null +++ "b/jay91537/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.java" @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); + + int[] arr = new int[11]; + arr[1] = 1; + arr[2] = 2; + arr[3] = 4; + + for(int i=4; i<11; i++) { + arr[i] = arr[i-1] + arr[i-2] + arr[i-3]; + } + + for(int j=0; j answerList = new ArrayList<>(); + + answerList.add(numbers[0]+numbers[1]); + + for(int k=0; k< numbers.length-1; k++) { + for (int i = k+1; i < numbers.length; i++) { + + for (int j = 0; j < answerList.size(); j++) { + + if ((numbers[k] + numbers[i]) == answerList.get(j)) { + break; + } + if(j== answerList.size()-1){ + answerList.add(numbers[k]+numbers[i]); + } + + } + + if (!answerList.contains(numbers[k] + numbers[i])) { + answerList.add(numbers[k] + numbers[i]); + } + + + } + } + + return answerList.stream().sorted().mapToInt(i -> i).toArray(); + } +} \ No newline at end of file diff --git "a/jay91537/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.java" "b/jay91537/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.java" new file mode 100644 index 0000000..430eb94 --- /dev/null +++ "b/jay91537/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.java" @@ -0,0 +1,48 @@ +import java.util.*; +class Solution { + public int[] solution(int n) { + int num = 0; + for(int i=1; i<=n; i++) { + num=num+i; + } + + int[] answer = new int[num]; + + int[][] matrix = new int[n+1][n+1]; + + int x=1; int y=0; + + int value =1; + + for(int i=1; i<=n; i++) { + for(int j=i; j<=n; j++) { + + if(i%3==1){ + y++; + } + else if(i%3==2){ + x++; + } + else if(i%3==0){ + x--; + y--; + } + + matrix[y][x] = value; + value++; + } + } + + int k = 0; + for(int i=1; i<=n; i++) { + for(int j=1; j<=n; j++){ + if(matrix[i][j] == 0) + break; + answer[k] = matrix[i][j]; + k++; + } + } + + return answer; + } +} \ No newline at end of file diff --git "a/jay91537/Week18/\354\265\234\354\206\214 \355\236\231.java" "b/jay91537/Week18/\354\265\234\354\206\214 \355\236\231.java" new file mode 100644 index 0000000..626b9a9 --- /dev/null +++ "b/jay91537/Week18/\354\265\234\354\206\214 \355\236\231.java" @@ -0,0 +1,27 @@ +import java.util.PriorityQueue; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + + PriorityQueue priorityQueue = new PriorityQueue<>(); + + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + + for (int i = 0; i < N; i++) { + int x = sc.nextInt(); + + if(x>0){ + priorityQueue.add(x); + } else if (x==0) { + if(priorityQueue.isEmpty()) System.out.println(0); + else { + System.out.println(priorityQueue.poll()); + } + } + } + + } + +} \ No newline at end of file diff --git "a/jay91537/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.java" "b/jay91537/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.java" new file mode 100644 index 0000000..bde7448 --- /dev/null +++ "b/jay91537/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.java" @@ -0,0 +1,44 @@ +import java.util.*; + +class Solution { + public int[] solution(String[] genres, int[] plays) { + ArrayList answer = new ArrayList<>(); + + // + HashMap numByGenres = new HashMap<>(); + + // , <2 : 150> , <3 : 800>> , , <4 : 2500>> + HashMap>music = new HashMap<>(); + + for(int i = 0; i< genres.length; i++) { + if(numByGenres.containsKey(genres[i])){ + numByGenres.put(genres[i], numByGenres.get(genres[i])+plays[i]); + music.get(genres[i]).put(i, plays[i]); + } else { + HashMap map = new HashMap<>(); + map.put(i, plays[i]); + music.put(genres[i], map); + numByGenres.put(genres[i], plays[i]); + } + } + + List keySet = new ArrayList<>(numByGenres.keySet()); + + // 장르를 총 조회수에 따라 내림차순으로 정렬 + Collections.sort(keySet, (s1, s2) -> numByGenres.get(s2) - numByGenres.get(s1)); + + // 정렬된 장르 리스트를 순회하며 각 장르별로 노래를 정렬 (내림차순으로!) + for(String key : keySet) { + HashMap map = music.get(key); + List genreKey = new ArrayList<>(map.keySet()); + + Collections.sort(genreKey, (s1, s2) -> map.get(s2) - map.get(s1)); + + answer.add(genreKey.get(0)); + if(genreKey.size()>1){ + answer.add(genreKey.get(1)); + } + } + return answer.stream().mapToInt(i -> i).toArray(); + } +} \ No newline at end of file diff --git "a/jay91537/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.java" "b/jay91537/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.java" new file mode 100644 index 0000000..b915e02 --- /dev/null +++ "b/jay91537/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.java" @@ -0,0 +1,30 @@ +import java.util.*; + +class Solution { + public String solution(String[] participant, String[] completion) { + HashMap completeMan = new HashMap<>(); + + ArrayList participantMan = new ArrayList<>(); + + for (int i = 0; i < completion.length; i++) { + if(completeMan.containsKey(completion[i])){ + completeMan.put(completion[i], completeMan.get(completion[i])+1); + } else { + completeMan.put(completion[i], 1); + } + } + + participantMan.addAll(Arrays.asList(participant)); + + String ans = null; + for (String person : participant) { + if (completeMan.containsKey(person) && completeMan.get(person) > 0) { + completeMan.put(person, completeMan.get(person) - 1); + } else { + ans = person; + break; + } + } + return ans; + } +} \ No newline at end of file diff --git "a/jay91537/Week19/\354\235\230\354\203\201.java" "b/jay91537/Week19/\354\235\230\354\203\201.java" new file mode 100644 index 0000000..05b190b --- /dev/null +++ "b/jay91537/Week19/\354\235\230\354\203\201.java" @@ -0,0 +1,24 @@ +import java.util.*; + +class Solution { + public int solution(String[][] clothes) { + + + HashMap clothesNum = new HashMap<>(); + + for (int i = 0; i < clothes.length; i++) { + if (clothesNum.containsKey(clothes[i][1])) { + clothesNum.put(clothes[i][1], clothesNum.get(clothes[i][1]) + 1); + } else { + clothesNum.put(clothes[i][1], 1); + + } + } + int answer = 1; + Iterator it = clothesNum.values().iterator(); + while (it.hasNext()) { + answer *= it.next() + 1; + } + return answer - 1; + } +} \ No newline at end of file diff --git "a/jay91537/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.java" "b/jay91537/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.java" new file mode 100644 index 0000000..4cfd2bd --- /dev/null +++ "b/jay91537/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.java" @@ -0,0 +1,21 @@ +import java.util.*; + +class Solution { + public boolean solution(String[] phone_book) { + + Arrays.sort(phone_book); + + for(int i=0; i numOfPo = new ArrayList<>(); + + for(int i=0; i< nums.length; i++) { + if(!numOfPo.contains(nums[i])) { + numOfPo.add(nums[i]); + } + } + + + int answer = 0; + + if(nums.length/2 > numOfPo.size()) { + answer = numOfPo.size(); + } else { + answer = nums.length/2; + } + return answer; + } +} \ No newline at end of file diff --git "a/jungyungee/Week1/\354\230\201\355\231\224\352\260\220\353\217\205\354\210\214.py" "b/jungyungee/Week1/\354\230\201\355\231\224\352\260\220\353\217\205\354\210\214.py" new file mode 100644 index 0000000..dca0fab --- /dev/null +++ "b/jungyungee/Week1/\354\230\201\355\231\224\352\260\220\353\217\205\354\210\214.py" @@ -0,0 +1,13 @@ +n = int(input()) +i=1 +j=0 +if n <= 10000: + num = str(i) + while j < n: + if "666" in num: + j = j + 1 + if j == n: + print(i) + break + i = i + 1 + num = str(i) diff --git "a/jungyungee/Week2/\353\213\250\354\226\264\354\240\225\353\240\254.py" "b/jungyungee/Week2/\353\213\250\354\226\264\354\240\225\353\240\254.py" new file mode 100644 index 0000000..c169019 --- /dev/null +++ "b/jungyungee/Week2/\353\213\250\354\226\264\354\240\225\353\240\254.py" @@ -0,0 +1,11 @@ +word_list =[] +num = int(input()) #입력받은 숫자를 단어의 개수로 +for i in range(num): + word_list.append(input()) + +deleted_list = list(set(word_list)) #중복제거 +deleted_list.sort() #길이 순 정렬 전, 알파벳 순 정렬 +deleted_list.sort( key=len ) #길이 순 정렬 + +for i in deleted_list: #출력 + print(i) \ No newline at end of file diff --git "a/jungyungee/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" "b/jungyungee/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" new file mode 100644 index 0000000..93ddf0b --- /dev/null +++ "b/jungyungee/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" @@ -0,0 +1,19 @@ +result_list = [] +def pytha(a, b, c): + if (((a ** 2) + (b ** 2) == (c ** 2)) + or ((a ** 2) + (c ** 2) == (b ** 2)) + or ((b ** 2) + (c ** 2) == (a ** 2))): + result_list.append("right") + else: + result_list.append("wrong") + +while True: + a, b, c = map(int,input().split()) + if (a or b or c) >= 30000: + break + elif a == 0 and b == 0 and c == 0: + for i in range(len(result_list)): + print(result_list[i], sep='\n') + break + else: + pytha(a, b, c) \ No newline at end of file diff --git "a/jungyungee/Week2/\355\214\251\355\206\240\353\246\254\354\226\2740\354\235\230\352\260\234\354\210\230.py" "b/jungyungee/Week2/\355\214\251\355\206\240\353\246\254\354\226\2740\354\235\230\352\260\234\354\210\230.py" new file mode 100644 index 0000000..92c4bad --- /dev/null +++ "b/jungyungee/Week2/\355\214\251\355\206\240\353\246\254\354\226\2740\354\235\230\352\260\234\354\210\230.py" @@ -0,0 +1,12 @@ +n = int(input()) #입력 +count = 0 + +for i in range(1, n+1): + if i % 125 == 0: + count = count + 3 + elif i % 25 == 0: + count = count + 2 + elif i % 5 == 0: + count = count + 1 + +print(count) \ No newline at end of file diff --git "a/jungyungee/Week3/\354\206\214\354\210\230\354\260\276\352\270\260.py" "b/jungyungee/Week3/\354\206\214\354\210\230\354\260\276\352\270\260.py" new file mode 100644 index 0000000..181f0cb --- /dev/null +++ "b/jungyungee/Week3/\354\206\214\354\210\230\354\260\276\352\270\260.py" @@ -0,0 +1,15 @@ +n = input() #정수 개수 +numbers = list(map(int, input().split())) #입력 받은 수 list +prime = 0 #소수 개수 +divisor = 0 #약수 개수 + +for i in numbers: + if ( i >= 2 ): + for j in range (i): + if ( i % (j+1) ) == 0: + divisor = divisor + 1 + if ( divisor == 2 ): + prime = prime + 1 + divisor = 0 + +print(prime) \ No newline at end of file diff --git "a/jungyungee/Week3/\354\233\260\354\273\264\355\202\244\355\212\270.py" "b/jungyungee/Week3/\354\233\260\354\273\264\355\202\244\355\212\270.py" new file mode 100644 index 0000000..186a1c8 --- /dev/null +++ "b/jungyungee/Week3/\354\233\260\354\273\264\355\202\244\355\212\270.py" @@ -0,0 +1,16 @@ +n = int(input()) #참가자 수 +sizelist = list(map(int, input().split())) #사이즈 별 신청자 수 +t, p = map(int, input().split()) #정수 티셔츠와 펜의 묶음 수 + +tnum = 0 +for i in range(len(sizelist)): + if (sizelist[i] % t == 0 ): #티셔츠 개수가 묶음의 배수일 경우 + tnum = tnum + sizelist[i]//t #묶음 수 만큼 + + else: + tnum = tnum + sizelist[i]//t + 1 #나누어떨어지지 않을 경우 몫 +1 + +pnum = n//p +pextra = n%p + +print(tnum) +print(pnum, pextra) \ No newline at end of file diff --git "a/jungyungee/Week3/\354\262\264\354\212\244\355\214\220.py" "b/jungyungee/Week3/\354\262\264\354\212\244\355\214\220.py" new file mode 100644 index 0000000..91e0636 --- /dev/null +++ "b/jungyungee/Week3/\354\262\264\354\212\244\355\214\220.py" @@ -0,0 +1,55 @@ +n, m = map(int, input().split()) #체스판 크기 입력 +board = [[0 for i in range (m)] for j in range (n)] #입력 받은 크기 만큼의 체스판을 위한 2차원 배열 생성 +for i in range (n): #입력 받은대로 board 채워넣기 + board[i] = list(input()) + +check = [[0 for i in range (8)] for j in range (8)] #색칠 개수 검사를 위한 함수에서 쓸 배열 선언 +cnt_list = [] #바꿀 칸 수들 저장할 리스트(이 중 최솟값을 선택) + +def color(check): + before_start_color = 0 + cnt = 0 #색 바꿔야하는 칸의 개수 + cnt_compare = [] #맨 왼쪽 윗칸이 W인 경우와 B인 경우에 따른 cnt 저장할 리스트 + for start in ['W', 'B']: + cnt = 0 + for i in check: + if ((start == 'B') or (before_start_color == 'W')): + before_start_color = 'B' + start = 0 + for j in i[0::2]: + if ( j != 'B'): + cnt += 1 + for j in i[1::2]: + if ( j!= 'W'): + cnt += 1 + elif ((start == 'W') or (before_start_color == 'B')): + before_start_color = 'W' + start = 0 + for j in i[0::2]: + if ( j != 'W'): + cnt += 1 + for j in i[1::2]: + if ( j!= 'B'): + cnt += 1 + cnt_compare.append(cnt) #두 경우에 따른 cnt를 비교를 위한 cmt_compare에 저장 + cnt = min(cnt_compare) # 두 경우 중 작은 값을 cnt에 저장 + + cnt_list.append(cnt) + +#가능한 8*8의 경우 +j, k, l, c = 0, 0, 0, 0 +while l <= (m-8): + while j <= (n-8) : + while k < (8+j) : + check[c] = board[k][l:l+8] + k += 1 + c += 1 + color(check) + j += 1 + k = j + c = 0 + j = 0 + k = 0 + l += 1 + +print(min(cnt_list)) #구해진 바꿀 칸 수(cnt)들 중 최솟값 선택 \ No newline at end of file diff --git "a/jungyungee/Week4/\353\266\204\355\225\264\355\225\251.py" "b/jungyungee/Week4/\353\266\204\355\225\264\355\225\251.py" new file mode 100644 index 0000000..d13753e --- /dev/null +++ "b/jungyungee/Week4/\353\266\204\355\225\264\355\225\251.py" @@ -0,0 +1,13 @@ +n = int(input()) + +for i in range (n): + num = sum(map(int, str(i))) + i + if num == n: + print(i) + break + else: + num = 0 + i =+ 1 + +if (num == 0): + print(0) \ No newline at end of file diff --git "a/jungyungee/Week4/\354\210\230\354\240\225\353\240\2542.py" "b/jungyungee/Week4/\354\210\230\354\240\225\353\240\2542.py" new file mode 100644 index 0000000..f8ceea3 --- /dev/null +++ "b/jungyungee/Week4/\354\210\230\354\240\225\353\240\2542.py" @@ -0,0 +1,14 @@ +import sys +input = sys.stdin.readline + +n = int(input().strip()) #수의 개수 +list = [] + +for i in range (n): + num = int(input().strip()) + list.append(num) + +list.sort() + +for j in range (n): + print(list[j]) \ No newline at end of file diff --git "a/jungyungee/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" "b/jungyungee/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" new file mode 100644 index 0000000..a1b9d37 --- /dev/null +++ "b/jungyungee/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" @@ -0,0 +1,16 @@ +output = [] + +while True: + n = input() + rev_n = n[::-1] + + if (n == '0'): + break + else: + if (n == rev_n): + output.append('yes') + else: + output.append('no') + +for j in output: + print(j) \ No newline at end of file diff --git "a/jungyungee/Week5/\353\202\230\354\235\264\354\210\234\354\240\225\353\240\254.py" "b/jungyungee/Week5/\353\202\230\354\235\264\354\210\234\354\240\225\353\240\254.py" new file mode 100644 index 0000000..7e1b18e --- /dev/null +++ "b/jungyungee/Week5/\353\202\230\354\235\264\354\210\234\354\240\225\353\240\254.py" @@ -0,0 +1,15 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +list = [] + +for i in range (n): + a, b = input().split() + a = int(a) + list.append([a,b]) + +list.sort(key=lambda x: x[0]) + +for a, b in list: + print(a, b) \ No newline at end of file diff --git "a/jungyungee/Week5/\353\215\251\354\271\230.py" "b/jungyungee/Week5/\353\215\251\354\271\230.py" new file mode 100644 index 0000000..eacc8ab --- /dev/null +++ "b/jungyungee/Week5/\353\215\251\354\271\230.py" @@ -0,0 +1,17 @@ +n = int(input()) +input_list = [] +output_list = [] + +for i in range (n): + x, y = map(int, input().split()) + input_list.append([x,y]) + +rank = 1 +for j in range (n): + for k in range (n): + if (input_list[j][0] < input_list[k][0]) and (input_list[j][1] < input_list[k][1]) : + rank += 1 + output_list.append(rank) + rank = 1 + +print(*output_list) \ No newline at end of file diff --git "a/jungyungee/Week5/\353\262\214\354\247\221.py" "b/jungyungee/Week5/\353\262\214\354\247\221.py" new file mode 100644 index 0000000..74f9b4d --- /dev/null +++ "b/jungyungee/Week5/\353\262\214\354\247\221.py" @@ -0,0 +1,14 @@ +n = int(input()) +i = 0 +sum = 1 + +while True: + if n == 1 : + print (1) + break + elif sum < n : + sum = sum + i * 6 + i += 1 + else: + print (i) + break \ No newline at end of file diff --git "a/jungyungee/Week6/\353\270\224\353\236\231\354\236\255.py" "b/jungyungee/Week6/\353\270\224\353\236\231\354\236\255.py" new file mode 100644 index 0000000..12fca31 --- /dev/null +++ "b/jungyungee/Week6/\353\270\224\353\236\231\354\236\255.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +n, m = map(int, input().split()) +cards = list(map(int, input().split())) + +i, result = 0, 0 +while i < n: + j = i + 1 + while j < n: + k = j + 1 + while k < n: + sum = cards[i]+cards[j]+cards[k] + if (sum <= m) and (sum > result): + result = sum + sum = 0 + k += 1 + j += 1 + i += 1 + +print(result) \ No newline at end of file diff --git "a/jungyungee/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/jungyungee/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..3f16208 --- /dev/null +++ "b/jungyungee/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +list = [] + +for i in range (n): + x, y = map(int, input().split()) + list.append([x,y]) + +list.sort(key = lambda x: (x[0], x[1])) +for j in list: + print(*j) \ No newline at end of file diff --git "a/jungyungee/Week6/\355\217\211\352\267\240.py" "b/jungyungee/Week6/\355\217\211\352\267\240.py" new file mode 100644 index 0000000..8d0c0cf --- /dev/null +++ "b/jungyungee/Week6/\355\217\211\352\267\240.py" @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +scores = list(map(int, input().split())) +m = max(scores) +sum = 0 + +for i in range(len(scores)): + sum = sum + (scores[i]/m * 100) + +print(sum/n) \ No newline at end of file diff --git a/jungyungee/Week7/hashing.py b/jungyungee/Week7/hashing.py new file mode 100644 index 0000000..0788ea7 --- /dev/null +++ b/jungyungee/Week7/hashing.py @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +l = int(input()) +string = list(input()) +alphabet_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] +sum = 0 + +for i in range(l): + index = alphabet_list.index(string[i]) + sum += ( index+1 ) * ( 31**i ) + +print( sum % 1234567891 ) \ No newline at end of file diff --git "a/jungyungee/Week7/\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" "b/jungyungee/Week7/\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" new file mode 100644 index 0000000..3d507a7 --- /dev/null +++ "b/jungyungee/Week7/\354\232\224\354\204\270\355\221\270\354\212\244\353\254\270\354\240\234.py" @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline +from collections import deque + +n, k = map(int, input().split()) +DQ = deque(range(1, n+1)) +result = [] + +while (len(DQ) > 0): + for i in range(1, k): + DQ.append(DQ.popleft()) + result.append(DQ.popleft()) + +print("<", end="") +print(*result, sep=', ', end="") +print(">") \ No newline at end of file diff --git "a/noeyeyh/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" "b/noeyeyh/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" new file mode 100644 index 0000000..89544c2 --- /dev/null +++ "b/noeyeyh/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" @@ -0,0 +1,10 @@ +n = int(input()) +count = 0 +number = 666 + +while count < n: + if '666' in str(number): + count += 1 + number += 1 + +print(number - 1) \ No newline at end of file diff --git "a/noeyeyh/Week10/\352\264\204\355\230\270.py" "b/noeyeyh/Week10/\352\264\204\355\230\270.py" new file mode 100644 index 0000000..118780e --- /dev/null +++ "b/noeyeyh/Week10/\352\264\204\355\230\270.py" @@ -0,0 +1,26 @@ +t = int(input()) +results = [] +opened = 0 + +for _ in range(t): + s = input() + + if s.count('(') != s.count(')'): + results.append('NO') + continue # 개수가 다르면 다음 문자열로 넘어감 + + + for i in s: + if i == '(': + opened += 1 + elif i == ')': + if opened > 0: # 열린 괄호가 있었으면 + opened -= 1 + else: # 열린 괄호 없이 닫힌 괄호가 먼저 나온 경우 + results.append('NO') + break + else: + results.append('YES') + +for i in results: + print(i) diff --git "a/noeyeyh/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" "b/noeyeyh/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" new file mode 100644 index 0000000..8dfb916 --- /dev/null +++ "b/noeyeyh/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" @@ -0,0 +1,38 @@ +results = [] + +while True: + s = input() + + if s == '.': + break + + stack = [] + valid = True + + for i in s: + if i == '(' or i == '[': + stack.append(i) # 열린 괄호를 스택에 추가 + elif i == ')': + if stack and stack[-1] == '(': # 짝이 맞는 경우 + stack.pop() + else: # 짝이 맞지 않는 경우 + results.append('no') + valid = False + break + elif i == ']': + if stack and stack[-1] == '[': # 짝이 맞는 경우 + stack.pop() + else: # 짝이 맞지 않는 경우 + results.append('no') + valid = False + break + + if valid: + if not stack: # 스택이 비어 있으면 모든 괄호가 닫힌 것 + results.append('yes') + else: + results.append('no') + + +for i in results: + print(i) diff --git "a/noeyeyh/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" "b/noeyeyh/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" new file mode 100644 index 0000000..226d783 --- /dev/null +++ "b/noeyeyh/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" @@ -0,0 +1,11 @@ +a, b, v = map(int, input().split()) +days=1 + +if v <= a: + print(days) +elif (v - b) % (a - b) == 0: + days = (v - b) // (a - b) + print(days) +else: + days = (v - b) // (a - b) + 1 + print(days) \ No newline at end of file diff --git "a/noeyeyh/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" "b/noeyeyh/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" new file mode 100644 index 0000000..26ecfbd --- /dev/null +++ "b/noeyeyh/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +l = [0 for x in range(10001)] + +for i in range(n): + l[int(input())] += 1 + +for i in range(10001): + for j in range(l[i]): + print(i) \ No newline at end of file diff --git "a/noeyeyh/Week11/\354\210\253\354\236\220\354\271\264\353\223\234 2.py" "b/noeyeyh/Week11/\354\210\253\354\236\220\354\271\264\353\223\234 2.py" new file mode 100644 index 0000000..d0b5a05 --- /dev/null +++ "b/noeyeyh/Week11/\354\210\253\354\236\220\354\271\264\353\223\234 2.py" @@ -0,0 +1,22 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +n_list = list(map(int, input().split())) + +m = int(input()) +m_list = list(map(int, input().split())) + +count_dict = {} +for num in n_list: + if num in count_dict: + count_dict[num] += 1 + else: + count_dict[num] = 1 + +results = [] + +for num in m_list: + results.append(count_dict.get(num, 0)) # 존재하지 않으면 0 + +print(*results) diff --git "a/noeyeyh/Week11/\354\240\234\353\241\234.py" "b/noeyeyh/Week11/\354\240\234\353\241\234.py" new file mode 100644 index 0000000..db21ecc --- /dev/null +++ "b/noeyeyh/Week11/\354\240\234\353\241\234.py" @@ -0,0 +1,11 @@ +k = int(input()) +l=[] + +for i in range(k): + n = int(input()) + if n != 0: + l.append(n) + else: + l.pop() + +print(sum(l)) \ No newline at end of file diff --git "a/noeyeyh/Week12/\354\212\244\355\203\235.py" "b/noeyeyh/Week12/\354\212\244\355\203\235.py" new file mode 100644 index 0000000..f362cf8 --- /dev/null +++ "b/noeyeyh/Week12/\354\212\244\355\203\235.py" @@ -0,0 +1,35 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +stack = [] +size = 0 + +for i in range(n): + l = list(input().split()) + + if l[0] == "push": + stack.append(l[1]) + size += 1 + + elif l[0] == "pop": + if size != 0: + print(stack.pop()) + size -= 1 + else: + print(-1) + + elif l[0] == "size": + print(size) + + elif l[0] == "empty": + if size: + print(0) + else: + print(1) + + else: + if size != 0: + print(stack[-1]) + else: + print(-1) \ No newline at end of file diff --git "a/noeyeyh/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" "b/noeyeyh/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" new file mode 100644 index 0000000..508d13e --- /dev/null +++ "b/noeyeyh/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline + +N , K = map(int,input().split()) + +def factorial(N): + result = 1 + for i in range(1, N + 1): + result *= i + return result + +print(factorial(N) // (factorial(K) * factorial(N-K))) diff --git "a/noeyeyh/Week12/\355\201\220.py" "b/noeyeyh/Week12/\355\201\220.py" new file mode 100644 index 0000000..ee4f3b8 --- /dev/null +++ "b/noeyeyh/Week12/\355\201\220.py" @@ -0,0 +1,42 @@ +from collections import deque +import sys +input = sys.stdin.readline + +n = int(input()) +q = deque() +size = 0 + +for i in range(n): + l = list(input().split()) + + if l[0] == "push": + q.append(l[1]) + size += 1 + + elif l[0] == "pop": + if size != 0: + print(q.popleft()) + size -= 1 + else: + print(-1) + + elif l[0] == "size": + print(size) + + elif l[0] == "empty": + if size: + print(0) + else: + print(1) + + elif l[0] == "front": + if size != 0: + print(q[0]) + else: + print(-1) + + else: + if size != 0: + print(q[-1]) + else: + print(-1) \ No newline at end of file diff --git a/noeyeyh/Week13/FizzBuzz.py b/noeyeyh/Week13/FizzBuzz.py new file mode 100644 index 0000000..272fd5f --- /dev/null +++ b/noeyeyh/Week13/FizzBuzz.py @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +def FizzBuzz(n): + if n % 15 == 0: + print("FizzBuzz") + elif n % 3 == 0: + print("Fizz") + elif n % 5 == 0: + print("Buzz") + else: + print(n) + +n = 0 + +for i in range(3, 0, -1): + x = input().strip() + if (x != "Fizz" and x != "Buzz" and x != "FizzBuzz"): + n = int(x) + i + +FizzBuzz(n) diff --git a/noeyeyh/Week13/solved.ac.py b/noeyeyh/Week13/solved.ac.py new file mode 100644 index 0000000..8803730 --- /dev/null +++ b/noeyeyh/Week13/solved.ac.py @@ -0,0 +1,28 @@ +import sys +input = sys.stdin.readline + +def round(number): + integer = int(number) + rest = number - integer + + if rest >= 0.5: + return integer + 1 + else: + return integer + +number = int(input().rstrip()) +level = [] + +for i in range(number): + level.append(int(input().rstrip())) + +level.sort() +new_number = round(number * 0.15) +count = number - (2 * new_number) + +if count <= 0: + print(0) +else: + total = sum(level[new_number:number - new_number]) + answer = round(total / count) + print(answer) diff --git "a/noeyeyh/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" "b/noeyeyh/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..5a7b786 --- /dev/null +++ "b/noeyeyh/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" @@ -0,0 +1,14 @@ +import sys +n = 10 ** 6 +isPrime = [True for x in range(n+1)] +isPrime[0], isPrime[1] = False, False + +for i in range(2, int(n**0.5)+1): + if isPrime[i]: + for j in range(i*2, n+1, i): + isPrime[j] = False + +m, n = map(int, sys.stdin.readline().split()) +for i in range(m, n+1): + if isPrime[i]: + print(i) \ No newline at end of file diff --git "a/noeyeyh/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/noeyeyh/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..09ba570 --- /dev/null +++ "b/noeyeyh/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,24 @@ +import sys +input = sys.stdin.readline + +k, n = map(int,input().split()) +list = [int(input()) for _ in range(k)] + +start = 1 +end = max(list) +result = 0 + +while start <= end: + mid = (start + end) // 2 + count = 0 + + for length in list : + count += length // mid + + if count >= n: + result = mid + start = mid + 1 + else: + end = mid - 1 + +print(result) diff --git "a/noeyeyh/Week14/\355\206\265\352\263\204\355\225\231.py" "b/noeyeyh/Week14/\355\206\265\352\263\204\355\225\231.py" new file mode 100644 index 0000000..89a9c45 --- /dev/null +++ "b/noeyeyh/Week14/\355\206\265\352\263\204\355\225\231.py" @@ -0,0 +1,48 @@ +import sys +input = sys.stdin.readline + +n = int(input().strip()) +numbers = [] + +for _ in range(n): + numbers.append(int(input().strip())) +numbers.sort() + +# 산술평균 +a = round(sum(numbers) / n) + +# 중앙값 +if n % 2 == 0: + b = (numbers[n // 2 - 1] + numbers[n // 2]) / 2 +else: + b = numbers[n // 2] + +# 최빈값 +frequency = {} +max_count = 0 +mode = [] + +for num in numbers: + frequency[num] = frequency.get(num, 0) + 1 + +for num, count in frequency.items(): + if count > max_count: + max_count = count + mode = [num] + elif count == max_count: + mode.append(num) # 동일한 빈도의 숫자 추가 + +# 최빈값 중 두 번째로 작은 값 선택하기 +mode.sort() +if len(mode) >= 2: + c = mode[1] +else: + c = mode[0] if mode else None + +# 범위 +d = max(numbers) - min(numbers) + +print(a) +print(b) +print(c) +print(d) diff --git "a/noeyeyh/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/noeyeyh/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..b4849ea --- /dev/null +++ "b/noeyeyh/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,32 @@ +from collections import deque +import sys +input = sys.stdin.readline + +n = int(input()) +results= [] + +for i in range(n): + N, M = map(int, input().split()) + q = deque(map(int, input().split())) + count = 0 + + while True: + if q[0] < max(q): + if M == 0: + M = len(q) - 1 + else: + M -= 1 + q.append(q.popleft()) + else: + if M != 0: + q.popleft() + M -= 1 + count += 1 + else: + count += 1 + break + + results.append(count) + +for i in results: + print(i) diff --git "a/noeyeyh/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" "b/noeyeyh/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" new file mode 100644 index 0000000..17b4494 --- /dev/null +++ "b/noeyeyh/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" @@ -0,0 +1,26 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) +arr = [] +index_map = {} + +for i in range(N): + arr.append(input().strip()) + +for i in range(N): + key = arr[i] + value = i + 1 + index_map[key] = value + + +for i in range(M): + query = input().strip() + + if query.isdigit(): + index = int(query) - 1 + print(arr[index]) + + else: + print(index_map[query]) + diff --git "a/noeyeyh/Week15/\353\223\243\353\263\264\354\236\241.py" "b/noeyeyh/Week15/\353\223\243\353\263\264\354\236\241.py" new file mode 100644 index 0000000..69c4c0b --- /dev/null +++ "b/noeyeyh/Week15/\353\223\243\353\263\264\354\236\241.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) +listen = [] +touch = set() +both = [] + +for i in range(N): + listen.append(input().strip()) + +for i in range(M): + touch.add(input().strip()) + +for i in listen: + if i in touch: + both.append(i) + +print(len(both)) +for i in sorted(both): + print(i) diff --git "a/noeyeyh/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" "b/noeyeyh/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" new file mode 100644 index 0000000..a3700ab --- /dev/null +++ "b/noeyeyh/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" @@ -0,0 +1,28 @@ +import sys +input = sys.stdin.readline + +n = int(input()) + +count = 1 +stack = [] +results = [] + +for i in range(n): + num = int(input()) + + while count <= num: + stack.append(count) + results.append('+') + count += 1 + + if stack[-1] == num: + stack.pop() + results.append('-') + + else: + print("NO") + break + +else: + for i in results: + print(i) diff --git "a/noeyeyh/Week15/\354\247\221\355\225\251.py" "b/noeyeyh/Week15/\354\247\221\355\225\251.py" new file mode 100644 index 0000000..d4dc2bc --- /dev/null +++ "b/noeyeyh/Week15/\354\247\221\355\225\251.py" @@ -0,0 +1,32 @@ +import sys +input = sys.stdin.readline + +M = int(input()) +S = set() + +for i in range(M): + arr = input().strip().split() + + if len(arr) == 1: + if arr[0] == 'all': + for i in range(1, 21): + S.add(i) + else: + S = set() + else: + op, num = arr[0], int(arr[1]) + + if op == 'add': + S.add(num) + elif op == 'remove': + S.discard(num) + elif op == 'check': + if num in S: + print(1) + else: + print(0) + elif op == 'toggle': + if num in S: + S.discard(num) + else: + S.add(num) diff --git "a/noeyeyh/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" "b/noeyeyh/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..dfc41b4 --- /dev/null +++ "b/noeyeyh/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" @@ -0,0 +1,14 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +d = [0] * (n + 1) + +for i in range(2, n + 1): + d[i] = d[i - 1] + 1 + if i % 3 == 0: + d[i] = min(d[i], d[i // 3] + 1) + if i % 2 == 0: + d[i] = min(d[i], d[i // 2] + 1) + +print(d[n]) \ No newline at end of file diff --git "a/noeyeyh/Week16/DFS\354\231\200 BFS.py" "b/noeyeyh/Week16/DFS\354\231\200 BFS.py" new file mode 100644 index 0000000..062ebe4 --- /dev/null +++ "b/noeyeyh/Week16/DFS\354\231\200 BFS.py" @@ -0,0 +1,35 @@ +import sys +input = sys.stdin.readline + +N, M, V = map(int, input().split()) + +graph = [[0]*(N+1) for i in range(N+1)] + +for i in range (M): + a,b = map(int,input().split()) + graph[a][b] = graph[b][a] = 1 + +visitedD = [0]*(N+1) +visitedB = [0]*(N+1) + +def dfs(V): + visitedD[V] = 1 + print(V, end=' ') + for i in range(1, N+1): + if graph[V][i] == 1 and visitedD[i] == 0: + dfs(i) + +def bfs(V): + queue = [V] + visitedB[V] = 1 + while queue: + V = queue.pop(0) + print(V, end = ' ') + for i in range(1, N+1): + if(visitedB[i] == 0 and graph[V][i] == 1): + queue.append(i) + visitedB[i] = 1 + +dfs(V) +print() +bfs(V) \ No newline at end of file diff --git "a/noeyeyh/Week16/\353\217\231\354\240\204 0.py" "b/noeyeyh/Week16/\353\217\231\354\240\204 0.py" new file mode 100644 index 0000000..55414b0 --- /dev/null +++ "b/noeyeyh/Week16/\353\217\231\354\240\204 0.py" @@ -0,0 +1,19 @@ +import sys +input = sys.stdin.readline + +n, k = map(int, input().split()) +l = [0 for i in range(n)] +count = 0 + +for i in range(n): + l.append(int(input())) +l.reverse() + +for i in range(n): + while k >= l[i]: + k -= l[i] + count += 1 + if k == 0: + break + +print(count) \ No newline at end of file diff --git "a/noeyeyh/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" "b/noeyeyh/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" new file mode 100644 index 0000000..7abaa41 --- /dev/null +++ "b/noeyeyh/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +T = int(input()) +f = [[0] * 2 for i in range(41)] + +f[0][0] = 1 +f[0][1] = 0 +f[1][0] = 0 +f[1][1] = 1 + +for i in range(2, 41): + f[i][0] = f[i - 1][0] + f[i - 2][0] + f[i][1] = f[i - 1][1] + f[i - 2][1] + +for i in range(T): + n = int(input()) + print(f[n][0], f[n][1]) diff --git a/noeyeyh/Week17/ATM.py b/noeyeyh/Week17/ATM.py new file mode 100644 index 0000000..31a787e --- /dev/null +++ b/noeyeyh/Week17/ATM.py @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +time = list(map(int, input(). split())) +time.sort() + +total = 0 + +for i in range(n): + total += time[i] * (n - i) + +print(total) \ No newline at end of file diff --git "a/noeyeyh/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/noeyeyh/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..387c135 --- /dev/null +++ "b/noeyeyh/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +n = int(input()) + +stairs = [0]*(301) +for i in range(1, n+1): + stairs[i] = int(input()) + +dp = [0] * 301 + +dp[1] = stairs[1] +dp[2] = stairs[1] + stairs[2] + +for i in range(3, n+1): + dp[i] = max((dp[i-3] + stairs[i-1]), dp[i-2]) + stairs[i] + +print(dp[n]) \ No newline at end of file diff --git "a/noeyeyh/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/noeyeyh/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..3f68044 --- /dev/null +++ "b/noeyeyh/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +n = int(input()) +m = int(input()) +graph = [[] for i in range(n+1)] +visited = [0]*(n+1) + +for i in range(m): + a,b = map(int,input().split()) + graph[a] += [b] + graph[b] += [a] + +def dfs(m): + visited[m] = 1 + for i in graph[m]: + if visited[i]==0: + dfs(i) + +dfs(1) +print(sum(visited)-1) \ No newline at end of file diff --git "a/noeyeyh/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" "b/noeyeyh/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" new file mode 100644 index 0000000..1a4aac8 --- /dev/null +++ "b/noeyeyh/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" @@ -0,0 +1,34 @@ +import sys +input = sys.stdin.readline +sys.setrecursionlimit(10**6) + +def dfs(start_x, start_y): + graphs[start_x][start_y] = 0 + + for i in range(4): + nx = start_x + dx[i] + ny = start_y + dy[i] + + if 0 <= nx < y and 0 <= ny < x and graphs[nx][ny] == 1: + dfs(nx, ny) + +dx = [-1, 1, 0, 0] +dy = [0, 0, -1, 1] + +t = int(input()) +for _ in range(t): + x, y, k = map(int, input().split()) + graphs = [[0] * x for _ in range(y)] + count = 0 + + for i in range(k): + xk, yk = map(int, input().split()) + graphs[yk][xk] = 1 + + for i in range(y): + for j in range(x): + if graphs[i][j] == 1: + dfs(i, j) + count += 1 + + print(count) diff --git "a/noeyeyh/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.py" "b/noeyeyh/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..be2369f --- /dev/null +++ "b/noeyeyh/Week18/1, 2, 3 \353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline + +t = int(input()) +n = [int(input()) for i in range(t)] + +dp = [0]*11 +dp[1] = 1 +dp[2] = 2 +dp[3] = 4 + +for i in range(4, 11): + dp[i] = dp[i-1] + dp[i-2] + dp[i-3] + +for i in range(t): + print(dp[n[i]]) \ No newline at end of file diff --git "a/noeyeyh/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" "b/noeyeyh/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..2519b86 --- /dev/null +++ "b/noeyeyh/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,8 @@ +def solution(numbers): + results = set() + + for i in range(len(numbers)): + for j in range(i + 1, len(numbers)): + results.add(numbers[i] + numbers[j]) + + return sorted(results) \ No newline at end of file diff --git "a/noeyeyh/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" "b/noeyeyh/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" new file mode 100644 index 0000000..e82bcc4 --- /dev/null +++ "b/noeyeyh/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" @@ -0,0 +1,26 @@ +def solution(n): + t = 1 + x = -1 + y = 0 + result = [] + matrix = [[0] * n for _ in range(n)] + + # 방향 설정: 아래(1, 0), 오른쪽(0, 1), 위쪽(-1, -1) + directions = [(1, 0), (0, 1), (-1, -1)] # (dx, dy) + + for i in range(n): + for j in range(i, n): + dx, dy = directions[i % 3] # 현재 방향에 따라 dx, dy 설정 + + x += dx + y += dy + + matrix[x][y] = t + t += 1 + + for i in matrix: + for j in i: + if j != 0: + result.append(j) + + return result \ No newline at end of file diff --git "a/noeyeyh/Week18/\354\265\234\354\206\214 \355\236\231.py" "b/noeyeyh/Week18/\354\265\234\354\206\214 \355\236\231.py" new file mode 100644 index 0000000..1c2fca4 --- /dev/null +++ "b/noeyeyh/Week18/\354\265\234\354\206\214 \355\236\231.py" @@ -0,0 +1,17 @@ +import sys +import heapq +input = sys.stdin.readline + +n = int(input()) +heap = [] + +for _ in range(n): + k = int(input().strip()) + if k != 0: + heapq.heappush(heap, k) + else: + if heap: + temp = heapq.heappop(heap) + print(temp) + else: + print(0) \ No newline at end of file diff --git "a/noeyeyh/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" "b/noeyeyh/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" new file mode 100644 index 0000000..7b45afd --- /dev/null +++ "b/noeyeyh/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" @@ -0,0 +1,28 @@ +def solution(genres, plays): + genres_plays = {} + genre_tracks = {} + answer = [] + + for i in range(len(genres)): + genre = genres[i] + play = plays[i] + + if genre in genres_plays: + genres_plays[genre] += play + else: + genres_plays[genre] = play + + if genre in genre_tracks: + genre_tracks[genre].append((play, i)) # (재생 횟수, 인덱스) 튜플로 저장 + else: + genre_tracks[genre] = [(play, i)] + + sorted_genres = sorted(genres_plays.items(), key=lambda x: x[1], reverse=True) + + for genre, _ in sorted_genres: + sorted_tracks = sorted(genre_tracks[genre], key=lambda x: x[0], reverse=True) + + for play_count, index in sorted_tracks[:2]: + answer.append(index) + + return answer diff --git "a/noeyeyh/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.py" "b/noeyeyh/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.py" new file mode 100644 index 0000000..b9b0c70 --- /dev/null +++ "b/noeyeyh/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273\355\225\234 \354\204\240\354\210\230.py" @@ -0,0 +1,9 @@ +from collections import Counter + +def solution(participant, completion): + p = Counter(participant) + c = Counter(completion) + + for i in p: + if p[i] > c[i]: + return i \ No newline at end of file diff --git "a/noeyeyh/Week19/\354\235\230\354\203\201.py" "b/noeyeyh/Week19/\354\235\230\354\203\201.py" new file mode 100644 index 0000000..9b65e9e --- /dev/null +++ "b/noeyeyh/Week19/\354\235\230\354\203\201.py" @@ -0,0 +1,14 @@ +def solution(clothes): + category_count = {} + answer = 1 + + for item, category in clothes: + if category in category_count: + category_count[category] += 1 + else: + category_count[category] = 1 + + for count in category_count.values(): + answer *= (count + 1) + + return answer - 1 \ No newline at end of file diff --git "a/noeyeyh/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" "b/noeyeyh/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" new file mode 100644 index 0000000..c23095d --- /dev/null +++ "b/noeyeyh/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" @@ -0,0 +1,9 @@ +def solution(phone_book): + phone_set = set(phone_book) + + for phone in phone_book: + for i in range(1, len(phone)): + if phone[:i] in phone_set: + return False + + return True \ No newline at end of file diff --git "a/noeyeyh/Week19/\355\217\260\354\274\223\353\252\254.py" "b/noeyeyh/Week19/\355\217\260\354\274\223\353\252\254.py" new file mode 100644 index 0000000..d08018f --- /dev/null +++ "b/noeyeyh/Week19/\355\217\260\354\274\223\353\252\254.py" @@ -0,0 +1,10 @@ +def solution(nums): + count = len(set(nums)) + half = len(nums) // 2 + + if count < half: + answer = count + else: + answer = half + + return answer \ No newline at end of file diff --git "a/noeyeyh/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" "b/noeyeyh/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..38151b0 --- /dev/null +++ "b/noeyeyh/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" @@ -0,0 +1,9 @@ +import sys + +n = int(input()) +arr = sys.stdin.read().split() + +arr = list(set(arr)) +arr.sort(key=lambda x: (len(x), x)) + +print(*arr, sep="\n") \ No newline at end of file diff --git "a/noeyeyh/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" "b/noeyeyh/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" new file mode 100644 index 0000000..4b0bf62 --- /dev/null +++ "b/noeyeyh/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" @@ -0,0 +1,14 @@ +while True: + arr = list(map(int, input().split())) + + arr.sort() + if arr[0] == 0 and arr[1] == 0 and arr[2] == 0: + break + + if arr[0] > 0 and arr[1] > 0 and arr[2] > 0: + if arr[0]**2 + arr[1]**2 == arr[2]**2: + print("right") + else: + print("wrong") + else: + print("wrong") \ No newline at end of file diff --git "a/noeyeyh/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" "b/noeyeyh/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" new file mode 100644 index 0000000..566ccb8 --- /dev/null +++ "b/noeyeyh/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" @@ -0,0 +1,15 @@ +import math + +n = int(input()) +result = math.factorial(n) + +string = str(result)[::-1] +count = 0 + +for i in string: + if i == '0': + count += 1 + else: + break + +print(count) \ No newline at end of file diff --git "a/noeyeyh/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" "b/noeyeyh/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" new file mode 100644 index 0000000..23ea7de --- /dev/null +++ "b/noeyeyh/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" @@ -0,0 +1,8 @@ +def solution(arr): + answer = [arr[0]] + + for i in range(1, len(arr)): + if arr[i] != arr[i - 1]: + answer.append(arr[i]) + + return answer \ No newline at end of file diff --git "a/noeyeyh/Week20/\352\270\260\353\212\245\352\260\234\353\260\234.py" "b/noeyeyh/Week20/\352\270\260\353\212\245\352\260\234\353\260\234.py" new file mode 100644 index 0000000..2891b4b --- /dev/null +++ "b/noeyeyh/Week20/\352\270\260\353\212\245\352\260\234\353\260\234.py" @@ -0,0 +1,24 @@ +import math + +def solution(progresses, speeds): + answer = [] + days = [] + + for i in range(len(progresses)): + day = math.ceil((100 - progresses[i]) / speeds[i]) + days.append(day) + + max_day = days[0] + count = 1 + + for i in range(1, len(days)): + if days[i] <= max_day: + count += 1 + else: + answer.append(count) + max_day = days[i] + count = 1 + + answer.append(count) + + return answer \ No newline at end of file diff --git "a/noeyeyh/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" "b/noeyeyh/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" new file mode 100644 index 0000000..09e2f1e --- /dev/null +++ "b/noeyeyh/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" @@ -0,0 +1,20 @@ +from collections import deque + +def solution(s): + answer = True + open = deque() + + for i in s: + if i == "(": + open.append(i) + else: + if open: + open.pop() + else: + answer = False + break + + if open: + answer = False + + return answer \ No newline at end of file diff --git "a/noeyeyh/Week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" "b/noeyeyh/Week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" new file mode 100644 index 0000000..b614fda --- /dev/null +++ "b/noeyeyh/Week20/\354\236\205\352\265\255\354\213\254\354\202\254.py" @@ -0,0 +1,21 @@ +def solution(n, times): + answer = 0 + left = 1 + right = max(times) * n + + while left <= right: + mid = (left + right) // 2 + people = 0 + + for i in times: + people += mid // i + if people >= n: + break + + if people >= n : + answer = mid + right = mid -1 + elif people < n : + left = mid + 1 + + return answer \ No newline at end of file diff --git "a/noeyeyh/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/noeyeyh/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..5d347b8 --- /dev/null +++ "b/noeyeyh/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,21 @@ +import sys +n = int(sys.stdin.readline()) +l = list(map(int, sys.stdin.readline().split())) +count = 0 + +def isPrime(num) : + if num == 1: + return False + if num == 2: + return True + + for i in range(2, num): + if num % i == 0: + return False + return True + +for i in range(n): + if isPrime(l[i]): + count += 1 + +print(count) \ No newline at end of file diff --git "a/noeyeyh/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" "b/noeyeyh/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" new file mode 100644 index 0000000..65415e2 --- /dev/null +++ "b/noeyeyh/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" @@ -0,0 +1,12 @@ +import sys +N = int(sys.stdin.readline()) +arr=list(map(int, sys.stdin.readline().split())) +T,P = map(int, sys.stdin.readline().split()) + +count=0 +for i in range(6): + count+=arr[i]//T + if (arr[i]%T!=0): + count+=1 +print(count) +print(N//P, N%P) \ No newline at end of file diff --git "a/noeyeyh/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" "b/noeyeyh/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" new file mode 100644 index 0000000..a6e12ed --- /dev/null +++ "b/noeyeyh/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" @@ -0,0 +1,31 @@ +n, m = map(int,input().split()) +board=[] +new=[] + +for i in range(n): + board.append(input()) + +for i in range(n-7): + for j in range(m-7): + white = 0 + black = 0 + for a in range(8): + for b in range(8): + if (a+b) % 2== 0 : + if board[a+i][b+j] != 'W': + white += 1 + else: + black += 1 + + else: + if board[a+i][b+j] != 'B': + white += 1 + else: + black += 1 + + if white <= black: + new.append(white) + else: + new.append(black) + +print(min(new)) \ No newline at end of file diff --git "a/noeyeyh/Week4/\353\266\204\355\225\264\355\225\251.py" "b/noeyeyh/Week4/\353\266\204\355\225\264\355\225\251.py" new file mode 100644 index 0000000..8813426 --- /dev/null +++ "b/noeyeyh/Week4/\353\266\204\355\225\264\355\225\251.py" @@ -0,0 +1,8 @@ +n = int(input()) +for i in range(1, n+1): + result = i + sum((map(int, str(i)))) + if result == n: + print(i) + break + elif i == n: + print(0) \ No newline at end of file diff --git "a/noeyeyh/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" "b/noeyeyh/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" new file mode 100644 index 0000000..7e38249 --- /dev/null +++ "b/noeyeyh/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" @@ -0,0 +1,9 @@ +n = int(input()) +l = [] +for i in range(n): + l.append(int(input())) + +l.sort() + +for i in l: + print(i) \ No newline at end of file diff --git "a/noeyeyh/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" "b/noeyeyh/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" new file mode 100644 index 0000000..355d584 --- /dev/null +++ "b/noeyeyh/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" @@ -0,0 +1,8 @@ +while True: + number = input().strip() + if number == '0': + break + elif number == number[::-1]: + print("yes") + else: + print("no") \ No newline at end of file diff --git "a/noeyeyh/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" "b/noeyeyh/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..1f5c5de --- /dev/null +++ "b/noeyeyh/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" @@ -0,0 +1,11 @@ +import sys +input = sys.stdin.read + +data = input().split() +n = int(data[0]) +member_lst = [(int(data[i]), data[i+1]) for i in range(1, len(data), 2)] + +member_lst.sort(key=lambda x: x[0]) + +for age, name in member_lst: + print(age, name) \ No newline at end of file diff --git "a/noeyeyh/Week5/\353\215\251\354\271\230.py" "b/noeyeyh/Week5/\353\215\251\354\271\230.py" new file mode 100644 index 0000000..5a3360b --- /dev/null +++ "b/noeyeyh/Week5/\353\215\251\354\271\230.py" @@ -0,0 +1,17 @@ +n = int(input()) +arr = [] + +for i in range(n): + arr.append(list(map(int, input().strip().split()))) + +ranks = [] + +for i in range(n): + rank = 1 + for j in range(n): + if arr[i][0] < arr[j][0] and arr[i][1] < arr[j][1]: + rank += 1 + ranks.append(rank) + +print(*ranks) + \ No newline at end of file diff --git "a/noeyeyh/Week5/\353\262\214\354\247\221.py" "b/noeyeyh/Week5/\353\262\214\354\247\221.py" new file mode 100644 index 0000000..1cc8f65 --- /dev/null +++ "b/noeyeyh/Week5/\353\262\214\354\247\221.py" @@ -0,0 +1,13 @@ +n = int(input()) + +if n == 1: + result = 1 +else: + result = 1 + room_count = 1 + + while room_count < n: + room_count += 6 * result + result += 1 + +print(result) \ No newline at end of file diff --git "a/noeyeyh/Week6/\353\270\224\353\236\231\354\236\255.py" "b/noeyeyh/Week6/\353\270\224\353\236\231\354\236\255.py" new file mode 100644 index 0000000..f5a04fa --- /dev/null +++ "b/noeyeyh/Week6/\353\270\224\353\236\231\354\236\255.py" @@ -0,0 +1,12 @@ +from itertools import combinations + +n, m = map(int, input().split()) +l = list(map(int, input().split())) +result = 0 + +for a, b, c in combinations(l, 3): + if a + b + c > m: + continue + result = max(result, a + b + c) + +print(result) \ No newline at end of file diff --git "a/noeyeyh/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/noeyeyh/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..d3e7bfd --- /dev/null +++ "b/noeyeyh/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,9 @@ +n = int(input()) +arr = [] + +for i in range(n): + arr.append(list(map(int, input().strip().split()))) + +arr.sort() +for i in range(n): + print(*arr[i]) \ No newline at end of file diff --git "a/noeyeyh/Week6/\355\217\211\352\267\240.py" "b/noeyeyh/Week6/\355\217\211\352\267\240.py" new file mode 100644 index 0000000..7fb8119 --- /dev/null +++ "b/noeyeyh/Week6/\355\217\211\352\267\240.py" @@ -0,0 +1,7 @@ +n = int(input()) +l = list(map(int, input(). split())) + +s = sum(l) +m = max(l) +average = ((100 * s) / m / n) +print(average) \ No newline at end of file diff --git a/noeyeyh/Week7/Hashing.py b/noeyeyh/Week7/Hashing.py new file mode 100644 index 0000000..4d17967 --- /dev/null +++ b/noeyeyh/Week7/Hashing.py @@ -0,0 +1,15 @@ +n = int(input()) +string = input() + +arr = [] +result = 0 + +M = 1234567891 # 큰 소수로 모듈러 값을 설정 + +for i in string: + arr.append(ord(i) - ord('a') + 1) + +for i in range(len(arr)): + result += (arr[i] * (31**i)) + +print(result % M) \ No newline at end of file diff --git "a/noeyeyh/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" "b/noeyeyh/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" new file mode 100644 index 0000000..5317488 --- /dev/null +++ "b/noeyeyh/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" @@ -0,0 +1,13 @@ +n, k = map(int, input().split()) +arr = [] +index = 0 +result = [] + +for i in range(n): + arr.append(i+1) + +while len(arr) > 0: + index = (index + k - 1) % len(arr) + result.append(arr.pop(index)) + +print("<" + ", ".join(map(str, result)) + ">") \ No newline at end of file diff --git "a/noeyeyh/Week8/\354\210\230 \354\260\276\352\270\260.py" "b/noeyeyh/Week8/\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..292bc23 --- /dev/null +++ "b/noeyeyh/Week8/\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,11 @@ +n = int(input()) +A = set(map(int, input().split())) + +m = int(input()) +l = list(map(int, input().split())) + +for i in l: + if i in A: + print(1) + else: + print(0) \ No newline at end of file diff --git "a/noeyeyh/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" "b/noeyeyh/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" new file mode 100644 index 0000000..56f9868 --- /dev/null +++ "b/noeyeyh/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" @@ -0,0 +1,10 @@ +n = int(input()) +l = [] +for i in range(n): + x, y = (map(int, input(). split())) + l.append((x, y)) + +l.sort(key = lambda x : (x[1], x[0])) + +for i in l: + print(i[0], i[1]) \ No newline at end of file diff --git "a/noeyeyh/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" "b/noeyeyh/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" new file mode 100644 index 0000000..78dfd14 --- /dev/null +++ "b/noeyeyh/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" @@ -0,0 +1,4 @@ +import math +a, b = map(int, input().split()) +print(math.gcd(a, b)) +print(math.lcm(a, b)) \ No newline at end of file diff --git "a/noeyeyh/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" "b/noeyeyh/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" new file mode 100644 index 0000000..7150021 --- /dev/null +++ "b/noeyeyh/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" @@ -0,0 +1,12 @@ +t = int(input()) + +for i in range(t): + k = int(input()) + n = int(input()) + l = list(range(1, n + 1)) + + for j in range(k): + for i in range(1, n): + l[i] += l[i - 1] + + print(l[-1]) diff --git "a/noeyeyh/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" "b/noeyeyh/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" new file mode 100644 index 0000000..1553092 --- /dev/null +++ "b/noeyeyh/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" @@ -0,0 +1,14 @@ +n = int(input()) + +result = 0 + +while n >= 0: + if n % 5 == 0: + result += n // 5 + print(result) + break + n -= 3 + result += 1 + +if n < 0: + print("-1") diff --git "a/noeyeyh/Week9/\354\271\264\353\223\2342.py" "b/noeyeyh/Week9/\354\271\264\353\223\2342.py" new file mode 100644 index 0000000..c0aeaa8 --- /dev/null +++ "b/noeyeyh/Week9/\354\271\264\353\223\2342.py" @@ -0,0 +1,10 @@ +from collections import deque + +n = int(input()) +l = deque(range(1, n + 1)) + +while len(l) > 1: + l.popleft() # 첫 번째 요소 삭제 + l.append(l.popleft()) # 다음 요소를 삭제하고 리스트의 끝으로 이동 + +print(l[0]) \ No newline at end of file diff --git "a/oyatplum/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" "b/oyatplum/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" new file mode 100644 index 0000000..a922e2d --- /dev/null +++ "b/oyatplum/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.py" @@ -0,0 +1,12 @@ +num = input() +outputList = [0] +output = 0 +for i in range(int(num)): + while True: + output += 1 + if "666" in str(output) and output > outputList[0]: + outputList[0] = output + break + else: + continue +print(str(outputList[0])) \ No newline at end of file diff --git "a/oyatplum/Week10/\352\264\204\355\230\270.py" "b/oyatplum/Week10/\352\264\204\355\230\270.py" new file mode 100644 index 0000000..0d28a60 --- /dev/null +++ "b/oyatplum/Week10/\352\264\204\355\230\270.py" @@ -0,0 +1,24 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +inputArr = [] + +for _ in range(N): + inputArr.append(input().strip()) + +for i in inputArr: + stack = [] + for j in i: + if len(stack) == 0: + stack.append(j) + continue + else: + if ((j == ")" and stack[-1] == "(")): + stack.pop() + else: + stack.append(j) + if len(stack) == 0: + print("YES") + else: + print("NO") \ No newline at end of file diff --git "a/oyatplum/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" "b/oyatplum/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" new file mode 100644 index 0000000..7540c5c --- /dev/null +++ "b/oyatplum/Week10/\352\267\240\355\230\225\354\236\241\355\236\214 \354\204\270\354\203\201.py" @@ -0,0 +1,26 @@ +import sys +input = sys.stdin.readline + +inputArr = [] +while True: + inputString = input().rstrip("\n") + if inputString == ".": + break + else: + inputArr.append(inputString) + +for i in inputArr: + stack = [] + for j in i: + if (j == "(" or j == ")" or j == "[" or j == "]") and len(stack) == 0: + stack.append(j) + else: + if (j == ")" and stack[-1] == "(") or (j == "]" and stack[-1] == "["): + stack.pop() + elif (j == "(" or j == ")" or j == "[" or j == "]"): + stack.append(j) + + if len(stack) == 0: + print("yes") + else: + print("no") \ No newline at end of file diff --git "a/oyatplum/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" "b/oyatplum/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" new file mode 100644 index 0000000..3157bc9 --- /dev/null +++ "b/oyatplum/Week10/\353\213\254\355\214\275\354\235\264\353\212\224 \354\230\254\353\235\274\352\260\200\352\263\240 \354\213\266\353\213\244.py" @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline + +a, b, v = map(int, input().split()) + +if a >= v: + print("1") +else: + if (v-b) % (a-b) == 0: + print((v-b) // (a-b)) + else: + print((v-b) // (a-b) + 1) \ No newline at end of file diff --git "a/oyatplum/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" "b/oyatplum/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" new file mode 100644 index 0000000..5b378c6 --- /dev/null +++ "b/oyatplum/Week11/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\260 3.py" @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +inputList = [0] * (10000 + 1) + +for i in range(N): + inputList[int(input())] += 1 + +for i in range(len(inputList)): + if inputList[i] != 0: + for _ in range(inputList[i]): + print(i) \ No newline at end of file diff --git "a/oyatplum/Week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" "b/oyatplum/Week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" new file mode 100644 index 0000000..496b027 --- /dev/null +++ "b/oyatplum/Week11/\354\210\253\354\236\220 \354\271\264\353\223\234 2.py" @@ -0,0 +1,23 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +cardList = list(map(int, input().split())) + +M = int(input()) +numList = list(map(int, input().split())) + +diction = {} + +for card in cardList: + if card in diction: + diction[card] += 1 + else: + diction[card] = 1 + +for num in numList: + result = diction.get(num) + if result == None: + print("0", end=" ") + else: + print(result, end=" ") \ No newline at end of file diff --git "a/oyatplum/Week11/\354\240\234\353\241\234.py" "b/oyatplum/Week11/\354\240\234\353\241\234.py" new file mode 100644 index 0000000..aa93140 --- /dev/null +++ "b/oyatplum/Week11/\354\240\234\353\241\234.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +K = int(input()) +stack = [] +sum = 0 + +for _ in range(K): + num = int(input()) + if num != 0: + stack.append(num) + else: + stack.pop() + +for i in stack: + sum += i + +print(sum) \ No newline at end of file diff --git "a/oyatplum/Week12/\354\212\244\355\203\235.py" "b/oyatplum/Week12/\354\212\244\355\203\235.py" new file mode 100644 index 0000000..cd5e3e9 --- /dev/null +++ "b/oyatplum/Week12/\354\212\244\355\203\235.py" @@ -0,0 +1,31 @@ +import sys +input = sys.stdin.readline + +N = (int(input())) +stack = [] +output = [] + +for _ in range(N): + command = input().split() + if command[0] == "push": + stack.append(command[1]) + elif command[0] == "pop": + if len(stack) == 0: + output.append("-1") + else: + output.append(stack.pop()) + elif command[0] == "size": + output.append(len(stack)) + elif command[0] == "empty": + if len(stack) == 0: + output.append("1") + else: + output.append("0") + elif command[0] == "top": + if len(stack) == 0: + output.append("-1") + else: + output.append(stack[-1]) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" "b/oyatplum/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" new file mode 100644 index 0000000..84feb09 --- /dev/null +++ "b/oyatplum/Week12/\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" @@ -0,0 +1,14 @@ +import sys +input = sys.stdin.readline + +N, K = map(int, input().split()) + +def factorial(a): + b = 1 + for i in range(1, a+1): + b *= i + return b + +output = factorial(N) // (factorial(K) * factorial(N - K)) + +print(output) \ No newline at end of file diff --git "a/oyatplum/Week12/\355\201\220.py" "b/oyatplum/Week12/\355\201\220.py" new file mode 100644 index 0000000..d9213e5 --- /dev/null +++ "b/oyatplum/Week12/\355\201\220.py" @@ -0,0 +1,37 @@ +from collections import deque +import sys +input = sys.stdin.readline + +N = (int(input())) +output = [] +queue = deque() + +for _ in range(N): + command = input().split() + if command[0] == "push": + queue.append(command[1]) + elif command[0] == "pop": + if len(queue) == 0: + output.append("-1") + else: + output.append(queue.popleft()) + elif command[0] == "size": + output.append(len(queue)) + elif command[0] == "empty": + if len(queue) == 0: + output.append("1") + else: + output.append("0") + elif command[0] == "front": + if len(queue) == 0: + output.append("-1") + else: + output.append(queue[0]) + elif command[0] == "back": + if len(queue) == 0: + output.append("-1") + else: + output.append(queue[-1]) + +for i in output: + print(i) \ No newline at end of file diff --git a/oyatplum/Week13/FizzBuzz.py b/oyatplum/Week13/FizzBuzz.py new file mode 100644 index 0000000..8131fbf --- /dev/null +++ b/oyatplum/Week13/FizzBuzz.py @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +n = 0 +for i in range(3,0,-1): + x = input().strip() + if x.isdigit(): + n = int(x) + i + +if n % 3 == 0 and n % 5 == 0: + print("FizzBuzz") +elif n % 3 == 0 and not(n % 5 == 0): + print("Fizz") +elif not(n % 3 == 0) and n % 5 == 0: + print("Buzz") +else: + print(n) \ No newline at end of file diff --git a/oyatplum/Week13/solved.ac.py b/oyatplum/Week13/solved.ac.py new file mode 100644 index 0000000..1d4d96f --- /dev/null +++ b/oyatplum/Week13/solved.ac.py @@ -0,0 +1,38 @@ +import sys +from collections import deque +input = sys.stdin.readline + +N = int(input()) +average = 0 +total = 0 +inputList = [] +queue = deque() + +def roundFunc(num): + if num - int(num) >= 0.5: + return int(num)+1 + else: + return int(num) + +percent = roundFunc(N*0.15) + +if N == 0: + print(0) +else: + for _ in range(N): + inputList.append(int(input())) + + inputList.sort() + + for i in inputList: + queue.append(i) + + for _ in range(percent): + queue.popleft() + queue.pop() + + for i in queue: + total += i + + average = roundFunc(total / len(queue)) + print(average) \ No newline at end of file diff --git "a/oyatplum/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" "b/oyatplum/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..9a63405 --- /dev/null +++ "b/oyatplum/Week13/\354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260.py" @@ -0,0 +1,22 @@ +import math +import sys +input = sys.stdin.readline + +M, N = map(int, input().split()) + +arr = [True for i in range(N+1)] +arr[0] = arr[1] = False + +for i in range(2, int(math.sqrt(N)) +1): + if arr[i] == True: + j = 2 + while True: + if i*j <= N: + arr[i*j] = False + j += 1 + continue + break + +for j in range(M, N+1): + if arr[j] == True: + print(j) \ No newline at end of file diff --git "a/oyatplum/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/oyatplum/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..17786be --- /dev/null +++ "b/oyatplum/Week14/\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,28 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) + +inputList = [] + +for i in range(N): + inputList.append(int(input())) + +start = 1 +maxLen = max(inputList) +result = 0 + +while start <= maxLen: + mid = (start + maxLen) // 2 + count = 0 + + for i in inputList: + count += i // mid + + if count >= M: + start = mid + 1 + result = mid + else: + maxLen = mid - 1 + +print(result) \ No newline at end of file diff --git "a/oyatplum/Week14/\355\206\265\352\263\204\355\225\231.py" "b/oyatplum/Week14/\355\206\265\352\263\204\355\225\231.py" new file mode 100644 index 0000000..40520f9 --- /dev/null +++ "b/oyatplum/Week14/\355\206\265\352\263\204\355\225\231.py" @@ -0,0 +1,30 @@ +import sys +from collections import Counter +input = sys.stdin.readline + +N = int(input()) +arr = [] +sum = 0 + +for _ in range(N): + inputNum = int(input().strip()) + sum += inputNum + arr.append(inputNum) + +arr.sort() + +a = Counter(arr).most_common(2) + +most = 0 +if len(a) > 1: + if a[0][1] == a[1][1]: + most = a[1][0] + else: + most = a[0][0] +else: + most = a[0][0] + +print(round(sum / N)) +print(arr[N//2]) +print(most) +print(max(arr) - min(arr)) \ No newline at end of file diff --git "a/oyatplum/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/oyatplum/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..d4a6799 --- /dev/null +++ "b/oyatplum/Week14/\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,38 @@ +import sys +from collections import deque +input = sys.stdin.readline + +T = int(input()) +outputList = [] + +for _ in range(T): + queue = deque() + N, M = map(int, input().split()) + inputList = input().split() + + for i in inputList: + queue.append(i) + + count = 0 + + while True: + if queue[0] < max(queue): + if M == 0: + M = len(queue) - 1 + else: + M -= 1 + queue.append(queue.popleft()) + continue + else: + if M != 0: + queue.popleft() + M -= 1 + count += 1 + continue + else: + count += 1 + break + outputList.append(count) + +for i in outputList: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" "b/oyatplum/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" new file mode 100644 index 0000000..ce45b3e --- /dev/null +++ "b/oyatplum/Week15/\353\202\230\353\212\224\354\225\274 \355\217\254\354\274\223\353\252\254 \353\247\210\354\212\244\355\204\260 \354\235\264\353\213\244\354\206\234.py" @@ -0,0 +1,24 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) + +pokemon = [0] +pokemon_dict = {} +output = [] + +for i in range(N): + mon = input().strip() + pokemon.append(mon) + pokemon_dict[mon] = i + 1 + +for _ in range(M): + Q = input().strip() + + if Q.isdigit(): + output.append(pokemon[int(Q)]) + else: + output.append(pokemon_dict[Q]) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week15/\353\223\243\353\263\264\354\236\241.py" "b/oyatplum/Week15/\353\223\243\353\263\264\354\236\241.py" new file mode 100644 index 0000000..2ca3474 --- /dev/null +++ "b/oyatplum/Week15/\353\223\243\353\263\264\354\236\241.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) + +NSet = set() +output = set() + +for _ in range(N): + NSet.add(input().strip()) + +for _ in range(M): + notSeen = input().strip() + if notSeen in NSet: + output.add(notSeen) + else: + continue + +print(len(output)) +for i in sorted(output): + print(i) \ No newline at end of file diff --git "a/oyatplum/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" "b/oyatplum/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" new file mode 100644 index 0000000..b53034b --- /dev/null +++ "b/oyatplum/Week15/\354\212\244\355\203\235 \354\210\230\354\227\264.py" @@ -0,0 +1,29 @@ +import sys +input = sys.stdin.readline +from collections import deque + +queue = deque() +pushNum = 1 +isPossible = 1 +output = [] +N = int(input().strip()) + +for i in range(N): + num = int(input().strip()) + + while pushNum <= num: + queue.append(pushNum) + output.append("+") + pushNum += 1 + + if queue[-1] == num: + queue.pop() + output.append("-") + else: + isPossible = 0 + +if isPossible == 1: + for i in output: + print(i) +else: + print("NO") \ No newline at end of file diff --git "a/oyatplum/Week15/\354\247\221\355\225\251.py" "b/oyatplum/Week15/\354\247\221\355\225\251.py" new file mode 100644 index 0000000..232cb1e --- /dev/null +++ "b/oyatplum/Week15/\354\247\221\355\225\251.py" @@ -0,0 +1,33 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +inputSet = set() + +for _ in range(N): + str_input = input().split() + command = str_input[0] + if len(str_input) == 2: + num = int(str_input[1]) + + if command == "add": + inputSet.add(num) + elif command == "remove": + inputSet.discard(num) + elif command == "check": + if num in inputSet: + print(1) + else: + print(0) + elif command == "toggle": + if num in inputSet: + inputSet.discard(num) + else: + inputSet.add(num) + else: + if command == "all": + inputSet = set() + for i in range(1,21): + inputSet.add(i) + elif command == "empty": + inputSet = set() \ No newline at end of file diff --git "a/oyatplum/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" "b/oyatplum/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..a50f556 --- /dev/null +++ "b/oyatplum/Week16/1\353\241\234 \353\247\214\353\223\244\352\270\260.py" @@ -0,0 +1,15 @@ +import sys +input = sys.stdin.readline + +T = int(input()) + +dp = [0] * (T + 1) + +for i in range(2, T + 1): + dp[i] = dp[i-1] + 1 + if i % 3 == 0: + dp[i] = min(dp[i], dp[i//3] + 1) + if i % 2 == 0: + dp[i] = min(dp[i], dp[i//2] + 1) + +print(dp[T]) \ No newline at end of file diff --git "a/oyatplum/Week16/DFS\354\231\200 BFS.py" "b/oyatplum/Week16/DFS\354\231\200 BFS.py" new file mode 100644 index 0000000..03677b0 --- /dev/null +++ "b/oyatplum/Week16/DFS\354\231\200 BFS.py" @@ -0,0 +1,37 @@ +import sys +input = sys.stdin.readline +from collections import deque + +N,M,V = map(int, input().split()) + +graph = [[0]*(N+1) for _ in range(N+1)] + +visitedD = [0]*(N+1) +visitedB = [0]*(N+1) + +for _ in range(M): + x,y = map(int, input().split()) + graph[x][y] = 1 + graph[y][x] = 1 + +def DFS(v): + visitedD[v] = 1 + print(v, end=" ") + for i in range(N+1): + if graph[v][i] == 1 and visitedD[i] == 0: + DFS(i) +def BFS(v): + q = deque() + q.append(v) + visitedB[v] = 1 + while q: + p = q.popleft() + print(p, end=" ") + for i in range(N+1): + if graph[p][i] == 1 and visitedB[i] == 0: + q.append(i) + visitedB[i] = 1 + +DFS(V) +print() +BFS(V) \ No newline at end of file diff --git "a/oyatplum/Week16/\353\217\231\354\240\204 0.py" "b/oyatplum/Week16/\353\217\231\354\240\204 0.py" new file mode 100644 index 0000000..68be6d7 --- /dev/null +++ "b/oyatplum/Week16/\353\217\231\354\240\204 0.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +N, K = map(int, input().split()) + +count = 0 +coin = [] + +for i in range(N): + coin.append(int(input().strip())) + +coin.reverse() + +for i in coin: + if K >= i: + count += K // i + K = K - (i * (K // i)) + continue + else: + continue +print(count) \ No newline at end of file diff --git "a/oyatplum/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" "b/oyatplum/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" new file mode 100644 index 0000000..1bc0f1d --- /dev/null +++ "b/oyatplum/Week16/\355\224\274\353\263\264\353\202\230\354\271\230 \355\225\250\354\210\230.py" @@ -0,0 +1,19 @@ +import sys +input = sys.stdin.readline + +zeroCount = [1,0,1] +oneCount = [0,1,1] + +T = int(input()) + +def fibo(n): + length = len(zeroCount) + if n >= length: + for i in range(length, n+1): + zeroCount.append(zeroCount[i-1] + zeroCount[i-2]) + oneCount.append(oneCount[i-1] + oneCount[i-2]) + print(zeroCount[n], oneCount[n]) + +for _ in range(T): + n = int(input()) + fibo(n) \ No newline at end of file diff --git a/oyatplum/Week17/ATM.py b/oyatplum/Week17/ATM.py new file mode 100644 index 0000000..cfa5613 --- /dev/null +++ b/oyatplum/Week17/ATM.py @@ -0,0 +1,14 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +P = list(map(int, input().split())) + +P.sort() +min = 0 + +for i, Ivalue in enumerate(P): + for j, Jvalue in enumerate(P): + if j <= i: + min += Jvalue +print(min) \ No newline at end of file diff --git "a/oyatplum/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/oyatplum/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..2781685 --- /dev/null +++ "b/oyatplum/Week17/\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +stairs = [0]*(301) +list = [0]*(301) + +for i in range(1, N+1): + stairs[i] = int(input().strip()) + +list[1] = stairs[1] +list[2] = stairs[1] + stairs[2] + +for i in range(3, N+1): + list[i] = max((list[i-3] + stairs[i-1] + stairs[i]), (list[i-2] + stairs[i])) + +print(list[N]) \ No newline at end of file diff --git "a/oyatplum/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/oyatplum/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..aca695e --- /dev/null +++ "b/oyatplum/Week17/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,26 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +M = int(input()) + +graph = [[0]*(N+1) for _ in range(N+1)] +visitedD = [0]*(N+1) +visitedB = [0]*(N+1) +count = 0 + +for _ in range(M): + x,y = map(int, input().split()) + graph[x][y] = 1 + graph[y][x] = 1 + +def DFS(v): + visitedD[v] = 1 + global count + count += 1 + for i in range(N+1): + if graph[v][i] == 1 and visitedD[i] == 0: + DFS(i) +DFS(1) + +print(count - 1) \ No newline at end of file diff --git "a/oyatplum/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" "b/oyatplum/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" new file mode 100644 index 0000000..f5109a5 --- /dev/null +++ "b/oyatplum/Week17/\354\234\240\352\270\260\353\206\215 \353\260\260\354\266\224.py" @@ -0,0 +1,39 @@ +import sys +input = sys.stdin.readline +from collections import deque + +T = int(input()) + +x = [0,1,0,-1] +y = [1,0,-1,0] +output = [] +def bfs(i,j, graph): + q = deque() + q.append([i,j]) + graph[i][j] = 0 + + while q: + k, l = q.popleft() + for i in range(4): + cx = x[i] + k + cy = y[i] + l + if 0 <= cx < M and 0 <= cy < N and graph[cx][cy] == 1: + q.append([cx, cy]) + graph[cx][cy] = 0 + +for _ in range(T): + M, N, K = map(int, input().split()) + graph = [[0]*N for _ in range(M)] + for _ in range(K): + a,b = map(int, input().split()) + graph[a][b] = 1 + count = 0 + for i in range(M): + for j in range(N): + if graph[i][j] == 1: + bfs(i,j, graph) + count += 1 + output.append(count) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week18/1,2,3 \353\215\224\355\225\230\352\270\260.py" "b/oyatplum/Week18/1,2,3 \353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..3ad6380 --- /dev/null +++ "b/oyatplum/Week18/1,2,3 \353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,22 @@ +import sys +input = sys.stdin.readline + +output = [] + +def func(n): + if n == 1: + return 1 + elif n == 2: + return 2 + elif n == 3: + return 4 + else: + return func(n-1) + func(n-2) + func(n-3) + +t = int(input()) +for _ in range(t): + n = int(input().strip()) + output.append(func(n)) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" "b/oyatplum/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..85b2f77 --- /dev/null +++ "b/oyatplum/Week18/\353\221\220 \352\260\234 \353\275\221\354\225\204\354\204\234 \353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,7 @@ +def solution(numbers): + output = set() + for xIndex, x in enumerate(numbers): + for yIndex, y in enumerate(numbers): + if xIndex != yIndex: + output.add(x+y) + return sorted(output) \ No newline at end of file diff --git "a/oyatplum/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" "b/oyatplum/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" new file mode 100644 index 0000000..5351b9f --- /dev/null +++ "b/oyatplum/Week18/\354\202\274\352\260\201 \353\213\254\355\214\275\354\235\264.py" @@ -0,0 +1,26 @@ +def solution(n): + t = 1 + x = -1 + y = 0 + output = [] + matrix = [[0]*n for _ in range(n)] + + for i in range(n): + for j in range(i, n): + if i % 3 == 0: #down + x += 1 + elif i % 3 == 1: #right + y += 1 + elif i % 3 == 2: #up + x -= 1 + y -= 1 + + matrix[x][y] = t + t += 1 + + for i in matrix: + for j in i: + if j != 0: + output.append(j) + + return output \ No newline at end of file diff --git "a/oyatplum/Week18/\354\265\234\354\206\214 \355\236\231.py" "b/oyatplum/Week18/\354\265\234\354\206\214 \355\236\231.py" new file mode 100644 index 0000000..d3c9ad2 --- /dev/null +++ "b/oyatplum/Week18/\354\265\234\354\206\214 \355\236\231.py" @@ -0,0 +1,21 @@ +import sys +import heapq +input = sys.stdin.readline + +heap = [] +output = [] + +N = int(input()) + +for _ in range(N): + x = int(input().strip()) + if x == 0: + if len(heap) == 0: + output.append(0) + else: + output.append(heapq.heappop(heap)) + else: + heapq.heappush(heap, x) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" "b/oyatplum/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" new file mode 100644 index 0000000..740c457 --- /dev/null +++ "b/oyatplum/Week19/\353\262\240\354\212\244\355\212\270\354\225\250\353\262\224.py" @@ -0,0 +1,20 @@ +def solution(genres, plays): + answer = [] + d1 = {} + d2 = {} + + for i, (j,k) in enumerate(zip(genres, plays)): + if j not in d1.keys(): + d1[j] = k + else: + d1[j] += k + if j not in d2.keys(): + d2[j] = [(k,i)] + else: + d2[j] += [(k,i)] + + for i,j in sorted(d1.items(), key=lambda x:x[1] ,reverse = True): + for k,v in sorted(d2[i], key=lambda x:(-x[0], x[1]))[:2]: + answer.append(v) + + return answer \ No newline at end of file diff --git "a/oyatplum/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273 \355\225\234 \354\204\240\354\210\230.py" "b/oyatplum/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273 \355\225\234 \354\204\240\354\210\230.py" new file mode 100644 index 0000000..7f12717 --- /dev/null +++ "b/oyatplum/Week19/\354\231\204\354\243\274\355\225\230\354\247\200 \353\252\273 \355\225\234 \354\204\240\354\210\230.py" @@ -0,0 +1,12 @@ +from collections import Counter + +def solution(participant, completion): + answer = '' + + p = Counter(participant) + c = Counter(completion) + + for i in p-c: + answer = i + + return answer \ No newline at end of file diff --git "a/oyatplum/Week19/\354\235\230\354\203\201.py" "b/oyatplum/Week19/\354\235\230\354\203\201.py" new file mode 100644 index 0000000..29b42f6 --- /dev/null +++ "b/oyatplum/Week19/\354\235\230\354\203\201.py" @@ -0,0 +1,12 @@ +def solution(clothes): + answer = 1 + d = {} + + for name, kind in clothes: + if kind in d.keys(): + d[kind] += [name] + else: + d[kind] = [name] + for kind in d: + answer *= len(d[kind]) + 1 + return answer - 1 \ No newline at end of file diff --git "a/oyatplum/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" "b/oyatplum/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" new file mode 100644 index 0000000..aa3e6c8 --- /dev/null +++ "b/oyatplum/Week19/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" @@ -0,0 +1,6 @@ +def solution(phone_book): + phone_book.sort() + for p1, p2 in zip(phone_book, phone_book[1:]): + if p2.startswith(p1): + return False + return True \ No newline at end of file diff --git "a/oyatplum/Week19/\355\217\260\354\274\223\353\252\254.py" "b/oyatplum/Week19/\355\217\260\354\274\223\353\252\254.py" new file mode 100644 index 0000000..767547c --- /dev/null +++ "b/oyatplum/Week19/\355\217\260\354\274\223\353\252\254.py" @@ -0,0 +1,11 @@ +def solution(nums): + answer = 0 + maxLen = len(set(nums)) + numLen = len(nums)//2 + + if maxLen < numLen: + answer = maxLen + else: + answer = numLen + + return answer \ No newline at end of file diff --git "a/oyatplum/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" "b/oyatplum/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..aa81207 --- /dev/null +++ "b/oyatplum/Week2/\353\213\250\354\226\264 \354\240\225\353\240\254.py" @@ -0,0 +1,14 @@ +import sys + +array = [] +num = int(sys.stdin.readline()) + +if 1 <= num <= 20000: + array = [input().strip() for _ in range(num)] + +duplicateSortedArr = list(set(array)) #중복 단어 제거 + +lenSortedArr = sorted(duplicateSortedArr, key=lambda x: (len(x), x)) #문자열 길이로 정렬 + +for i in lenSortedArr: + print(i) diff --git "a/oyatplum/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" "b/oyatplum/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" new file mode 100644 index 0000000..b8ad2c9 --- /dev/null +++ "b/oyatplum/Week2/\354\247\201\352\260\201\354\202\274\352\260\201\355\230\225.py" @@ -0,0 +1,17 @@ +import sys +answer = [] + +while True: + a, b, c = map(int, sys.stdin.readline().split()) + a, b, c = sorted([a, b, c]) + if a == 0 and b == 0 and c == 0: + break + else: + if 0 < a < 30000 and 0 < b < 30000 and 0 < c < 30000: + if a**2 + b**2 == c**2: + answer.append("right") + else: + answer.append("wrong") + continue +for i in answer: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" "b/oyatplum/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" new file mode 100644 index 0000000..06756d2 --- /dev/null +++ "b/oyatplum/Week2/\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230.py" @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline +num = int(input()) +total = 1 +count = 0 + +for i in range(num): + total *= i+1 + +listNum = list(reversed(str(total))) + +for i in listNum: + if i == '0': + count += 1 + else: + break +print(count) \ No newline at end of file diff --git "a/oyatplum/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" "b/oyatplum/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" new file mode 100644 index 0000000..7042c14 --- /dev/null +++ "b/oyatplum/Week20/\352\260\231\354\235\200 \354\210\253\354\236\220\353\212\224 \354\213\253\354\226\264.py" @@ -0,0 +1,13 @@ +def solution(arr): + answer = [] + for i in arr: + if len(answer) == 0: + answer.append(i) + else: + k = answer.pop() + if i == k: + answer.append(i) + else: + answer.append(k) + answer.append(i) + return answer \ No newline at end of file diff --git "a/oyatplum/Week20/\352\270\260\353\212\245 \352\260\234\353\260\234.py" "b/oyatplum/Week20/\352\270\260\353\212\245 \352\260\234\353\260\234.py" new file mode 100644 index 0000000..7246ad2 --- /dev/null +++ "b/oyatplum/Week20/\352\270\260\353\212\245 \352\260\234\353\260\234.py" @@ -0,0 +1,22 @@ +answer = [] + +def solution(progresses, speeds): + global answer + num = 0 + while progresses[0] < 100: + for i, (j,k) in enumerate(zip(progresses, speeds)): + progresses[i] = j + k + + for i in progresses[:]: + if i >= 100: + progresses.pop(0) + speeds.pop(0) + num += 1 + else: + break + answer.append(num) + + if len(progresses) == 0: + return answer + else: + return solution(progresses, speeds) \ No newline at end of file diff --git "a/oyatplum/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" "b/oyatplum/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" new file mode 100644 index 0000000..3b08e90 --- /dev/null +++ "b/oyatplum/Week20/\354\230\254\353\260\224\353\245\270 \352\264\204\355\230\270.py" @@ -0,0 +1,18 @@ +from collections import deque + +def solution(s): + queue = deque() + for i in s: + if len(queue) == 0: + queue.append(i) + else: + temp = queue.pop() + if temp == "(" and i == ")": + continue + else: + queue.append(temp) + queue.append(i) + if len(queue) == 0: + return True + else: + return False \ No newline at end of file diff --git "a/oyatplum/Week20/\354\236\205\352\265\255 \354\213\254\354\202\254.py" "b/oyatplum/Week20/\354\236\205\352\265\255 \354\213\254\354\202\254.py" new file mode 100644 index 0000000..8e164b9 --- /dev/null +++ "b/oyatplum/Week20/\354\236\205\352\265\255 \354\213\254\354\202\254.py" @@ -0,0 +1,21 @@ +def solution(n, times): + total = 0 + left = 1 + right = max(times) * n + + while left <= right: + mid = (left + right) // 2 + people = 0 + + for time in times: + people += mid // time + if people >= n: + break + + if people >= n : + total = mid + right = mid -1 + elif people < n : + left = mid + 1 + + return total \ No newline at end of file diff --git "a/oyatplum/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/oyatplum/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..6c42b58 --- /dev/null +++ "b/oyatplum/Week3/\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,20 @@ +import sys +input = sys.stdin.readline +count = 0 + +total = int(input()) +numList = list(map(int, input().split())) + +for i in numList: + if i == 1: + total -= 1 + continue + else: + for j in range(2, i): + if i % j == 0: + count += 1 + break + else: + continue + +print(total - count) \ No newline at end of file diff --git "a/oyatplum/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" "b/oyatplum/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" new file mode 100644 index 0000000..65ae46a --- /dev/null +++ "b/oyatplum/Week3/\354\233\260\354\273\264 \355\202\244\355\212\270.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline +count = 0 + +total = int(input()) +shirtSizeList = list(map(int, input().split())) +T, P = map(int, input().split()) + +for i in shirtSizeList: + if i == 0: + continue + elif i <= T: + count += 1 + else: + count += (i - 1) // T + 1 + +print(count) +print(total // P, total % P) \ No newline at end of file diff --git "a/oyatplum/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" "b/oyatplum/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" new file mode 100644 index 0000000..b025ec0 --- /dev/null +++ "b/oyatplum/Week3/\354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260.py" @@ -0,0 +1,32 @@ +import sys +input = sys.stdin.readline + +a, b = map(int, input().split()) +board = [] +result = [] + +for _ in range(a): + board.append(input()) + +for i in range(a-7): + for j in range(b-7): + startW = 0 + startB = 0 + + for k in range(i, i+8): + for l in range(j, j+8): + if (k + l) % 2 == 0: + if board[k][l] != 'W': + startW += 1 + if board[k][l] != 'B': + startB +=1 + else: + if board[k][l] != 'B': + startW +=1 + if board[k][l] != 'W': + startB +=1 + + result.append(startW) + result.append(startB) + +print(min(result)) \ No newline at end of file diff --git "a/oyatplum/Week4/\353\266\204\355\225\264\355\225\251.py" "b/oyatplum/Week4/\353\266\204\355\225\264\355\225\251.py" new file mode 100644 index 0000000..5a330db --- /dev/null +++ "b/oyatplum/Week4/\353\266\204\355\225\264\355\225\251.py" @@ -0,0 +1,15 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +min = 0 + +for i in range(1, N): + total = i + for j in str(i): + total += int(j) + if total == N: + min = i + break + +print(min) \ No newline at end of file diff --git "a/oyatplum/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" "b/oyatplum/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" new file mode 100644 index 0000000..1119f98 --- /dev/null +++ "b/oyatplum/Week4/\354\210\230 \354\240\225\353\240\254\355\225\230\352\270\2602.py" @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +total = int(input()) +inputList = [] + +for i in range(total): + inputList.append(int(input())) + +inputList.sort() + +for i in inputList: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" "b/oyatplum/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" new file mode 100644 index 0000000..8658029 --- /dev/null +++ "b/oyatplum/Week4/\355\214\260\353\246\260\353\223\234\353\241\254\354\210\230.py" @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +inputArr = [] + +while True: + a = int(input()) + if a == 0: + break + else: + inputArr.append(a) + +for i in inputArr: + if str(i) == str(i)[::-1]: + print("yes") + else: + print("no") \ No newline at end of file diff --git "a/oyatplum/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" "b/oyatplum/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" new file mode 100644 index 0000000..b6de734 --- /dev/null +++ "b/oyatplum/Week5/\353\202\230\354\235\264\354\210\234 \354\240\225\353\240\254.py" @@ -0,0 +1,20 @@ +import sys +input = sys.stdin.readline + +inputNum = int(input()) +person_list = [] + +for i in range(inputNum): + person = [] + a, b = map(str, input().split()) + person.append(int(a)) + person.append(b) + person_list.append(person) + +person_list.sort(key=lambda person_list: person_list[0]) + + +for per in person_list: + for i in per: + print(i, end=" ") + print(sep="\n") \ No newline at end of file diff --git "a/oyatplum/Week5/\353\215\251\354\271\230.py" "b/oyatplum/Week5/\353\215\251\354\271\230.py" new file mode 100644 index 0000000..2371da7 --- /dev/null +++ "b/oyatplum/Week5/\353\215\251\354\271\230.py" @@ -0,0 +1,21 @@ +import sys +input = sys.stdin.readline + +inputNum = int(input()) +person_list = [] + +for i in range(inputNum): + person = [] + a, b = map(str, input().split()) + person.append(int(a)) + person.append(int(b)) + person_list.append(person) + +for i in person_list: + tall = 0 + for j in person_list: + if i[0] < j[0] and i[1] < j[1]: + tall += 1 + else: + continue + print(tall + 1, end=" ") \ No newline at end of file diff --git "a/oyatplum/Week5/\353\262\214\354\247\221.py" "b/oyatplum/Week5/\353\262\214\354\247\221.py" new file mode 100644 index 0000000..36ad32a --- /dev/null +++ "b/oyatplum/Week5/\353\262\214\354\247\221.py" @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline + +inputNum = int(input()) + +if inputNum == 1: + print("1") +else: + level = 1 + while True: + if inputNum <= 3*level*(level+1) + 1: + print(level+1) + break + else: + level += 1 + continue \ No newline at end of file diff --git "a/oyatplum/Week6/\353\270\224\353\236\231\354\236\255.py" "b/oyatplum/Week6/\353\270\224\353\236\231\354\236\255.py" new file mode 100644 index 0000000..e5687af --- /dev/null +++ "b/oyatplum/Week6/\353\270\224\353\236\231\354\236\255.py" @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) +cardList = list(map(int, input().split())) +sumList = [] + +for i in range(N-2): + for j in range(i+1, N-1): + for k in range(j+1, N): + sum = cardList[i] + cardList[j] + cardList[k] + if (sum <= M): + sumList.append(sum) + +sortedList = sorted(set(sumList), reverse=True) +print(sortedList[0]) \ No newline at end of file diff --git "a/oyatplum/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/oyatplum/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..9df6161 --- /dev/null +++ "b/oyatplum/Week6/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +coordinates = [] + +N = int(input()) + +for i in range(N): + xyList =[] + a,b = map(int, input().split()) + xyList.append(a) + xyList.append(b) + coordinates.append(xyList) + +coordinates.sort(key=lambda coordinates: (coordinates[0], coordinates[1])) + +for i,j in coordinates: + print(i, j) \ No newline at end of file diff --git "a/oyatplum/Week6/\355\217\211\352\267\240.py" "b/oyatplum/Week6/\355\217\211\352\267\240.py" new file mode 100644 index 0000000..417f90e --- /dev/null +++ "b/oyatplum/Week6/\355\217\211\352\267\240.py" @@ -0,0 +1,12 @@ +import sys +input = sys.stdin.readline + +count = int(input()) +inputList = list(map(int, input().split())) +maxNum = max(inputList) +sum = 0 + +for i in range(count): + inputList[i] = inputList[i]/maxNum*100 + sum += inputList[i] +print(sum/count) \ No newline at end of file diff --git a/oyatplum/Week7/Hashing.py b/oyatplum/Week7/Hashing.py new file mode 100644 index 0000000..af5df32 --- /dev/null +++ b/oyatplum/Week7/Hashing.py @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +alphaList = [chr(c) for c in range(97,123)] + +L = int(input()) +stringList = list(input().strip()) + +sum = 0 +M = 1234567891 + +for i in range(L): + for j in alphaList: + if stringList[i] == j: + sum = sum + ((alphaList.index(j) + 1)*(31**i)) + +print(sum % M) \ No newline at end of file diff --git "a/oyatplum/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" "b/oyatplum/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" new file mode 100644 index 0000000..0f484fa --- /dev/null +++ "b/oyatplum/Week7/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0.py" @@ -0,0 +1,20 @@ +from collections import deque + +queue = deque() +an = [] + +N, K = map(int, input().split()) + +for i in range(1, N+1): + queue.append(i) + +while queue: + for i in range(K-1): + queue.append(queue.popleft()) + an.append(queue.popleft()) + +print("<", end="") +for i in range(N - 1): + print(an[i], end=", ") +print(an[N - 1], end="") +print(">") \ No newline at end of file diff --git "a/oyatplum/Week8/\354\210\230 \354\260\276\352\270\260.py" "b/oyatplum/Week8/\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..b945800 --- /dev/null +++ "b/oyatplum/Week8/\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,13 @@ +import sys +input = sys.stdin.readline + +N = int(input()) +A_List = set(map(int, input().split())) +M = int(input()) +M_List = list(map(int, input().split())) + +for i in M_List: + if i in A_List: + print("1") + else: + print("0") \ No newline at end of file diff --git "a/oyatplum/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" "b/oyatplum/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" new file mode 100644 index 0000000..50a3119 --- /dev/null +++ "b/oyatplum/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +N = int(input()) + +coordinate = [] + +for _ in range(N): + arr = [] + a, b = (map(int, input().split())) + arr.append(a) + arr.append(b) + coordinate.append(arr) + +coordinate.sort(key=lambda coordinate: (coordinate[1], coordinate[0])) + +for i, j in coordinate: + print(i,j) \ No newline at end of file diff --git "a/oyatplum/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" "b/oyatplum/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" new file mode 100644 index 0000000..309cb47 --- /dev/null +++ "b/oyatplum/Week8/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200 \354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" @@ -0,0 +1,15 @@ +import sys +input = sys.stdin.readline + +a, b = map(int, input().split()) + +while True: + Max = 1 + Min = 1 + for i in range(1, (min(a, b) + 1)): + if a % i == 0 and b % i == 0: + Max = i + print(Max) + Min = (a // Max) * (b // Max) * Max + print(Min) + break \ No newline at end of file diff --git "a/oyatplum/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" "b/oyatplum/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" new file mode 100644 index 0000000..089a419 --- /dev/null +++ "b/oyatplum/Week9/\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274.py" @@ -0,0 +1,28 @@ +import sys + +input = sys.stdin.readline + +T = int(input()) +output = [] + +for i in range(T): + K = int(input()) + N = int(input()) + Floor = [[0 for j in range(N)] for i in range(K + 1)] + for k in range(N): + Floor[0][k] = k + 1 + + for j in range(1,K+1): + for k in range(N): + sum = 0 + for l in range(N): + if k < l: + break + else: + sum += Floor[j-1][l] + continue + Floor[j][k] = sum + output.append(Floor[K][N-1]) + +for i in output: + print(i) \ No newline at end of file diff --git "a/oyatplum/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" "b/oyatplum/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" new file mode 100644 index 0000000..5cd31c3 --- /dev/null +++ "b/oyatplum/Week9/\354\204\244\355\203\225 \353\260\260\353\213\254.py" @@ -0,0 +1,19 @@ +import sys +input = sys.stdin.readline + +N = int(input()) + +big = 5 +small = 3 +output = 0 + +while N >= 0: + if N % big == 0: + output += N // big + print(output) + break + N -= 3 + output += 1 + +else: + print("-1") \ No newline at end of file diff --git "a/oyatplum/Week9/\354\271\264\353\223\234 2.py" "b/oyatplum/Week9/\354\271\264\353\223\234 2.py" new file mode 100644 index 0000000..3ef6783 --- /dev/null +++ "b/oyatplum/Week9/\354\271\264\353\223\234 2.py" @@ -0,0 +1,19 @@ +from collections import deque +import sys + +input = sys.stdin.readline +queue = deque() + +N = int(input()) + +for i in range(1,N+1): + queue.append(i) + +while True: + if len(queue) == 1: + break + queue.popleft() + queue.append(queue.popleft()) + continue + +print(queue.popleft()) \ No newline at end of file diff --git "a/uoo6uoow/Week1/.\354\230\201\355\231\224\352\260\220\353\217\205.swp" "b/uoo6uoow/Week1/.\354\230\201\355\231\224\352\260\220\353\217\205.swp" deleted file mode 100644 index de7be5c..0000000 Binary files "a/uoo6uoow/Week1/.\354\230\201\355\231\224\352\260\220\353\217\205.swp" and /dev/null differ diff --git "a/uoo6uoow/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.java" "b/uoo6uoow/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.java" new file mode 100644 index 0000000..ad45346 --- /dev/null +++ "b/uoo6uoow/Week1/\354\230\201\355\231\224\352\260\220\353\217\205 \354\210\214.java" @@ -0,0 +1,27 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + int N = scanner.nextInt(); + System.out.println(solution(N)); + } + + public static int solution(int N) { + int answer = 0; + ArrayList sixList = new ArrayList<>(); ///666이 들어간 정수 배열 + boolean contain; // 666이 들어있는지 확인하는 플래그 + + for (int i = 666; i < 10000000; i++) { + String num = String.valueOf(i); //i를 문자열로 저장함 + contain = num.contains("666"); //문자열로 저장된 i가 666을 포함하는지 확인, 포함하면 true + + if (contain) { + sixList.add(i); //배열에 666포함하는 숫자 넣기 + } + } + + answer = sixList.get(N - 1); + return answer; + } \ No newline at end of file diff --git "a/uoo6uoow/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.java" "b/uoo6uoow/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.java" new file mode 100644 index 0000000..3611411 --- /dev/null +++ "b/uoo6uoow/Week8/\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260 2.java" @@ -0,0 +1,34 @@ +import java.io.*; +import java.util.Arrays; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); + + int n = Integer.parseInt(reader.readLine()); + int [][] coordinate = new int[n][2]; + + for (int i = 0; i < n; i++) { + String input = reader.readLine(); + String[] str = input.split(" "); + coordinate[i][0] = Integer.parseInt(str[0]); + coordinate[i][1] = Integer.parseInt(str[1]); + } + + Arrays.sort(coordinate, (a, b) -> { + if(a[1] != b[1]){ + return Integer.compare(a[1],b[1]); + }else{ + return Integer.compare(a[0], b[0]); + } + }); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < n; i++) { + sb.append(coordinate[i][0]).append(" ").append(coordinate[i][1]).append('\n'); + } + writer.write(sb.toString()); + writer.flush(); + } +} \ No newline at end of file