From 89cc3bb1efb8e4accddf1314e10b7aafb78d7450 Mon Sep 17 00:00:00 2001 From: urjimyu <92876819+urjimyu@users.noreply.github.com> Date: Thu, 16 Nov 2023 23:21:50 +0900 Subject: [PATCH 1/2] solution: solved problem 12925, 12931 --- "\354\247\200\353\257\274/week6/12925.py" | 13 +++++++++++++ "\354\247\200\353\257\274/week6/12931.py" | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 "\354\247\200\353\257\274/week6/12925.py" create mode 100644 "\354\247\200\353\257\274/week6/12931.py" diff --git "a/\354\247\200\353\257\274/week6/12925.py" "b/\354\247\200\353\257\274/week6/12925.py" new file mode 100644 index 0000000..b780327 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/12925.py" @@ -0,0 +1,13 @@ +# Level 1 - 문자열 정수로 바꾸기 +def solution(s): + return int(s) + +# 다른 풀이 - 알고리즘 공부용 풀이 +def strToInt(str): + result = 0 + for idx, number in enumerate(str[::-1]): + if number == '-': + result *= -1 + else: + result += int(number) * (10 ** idx) + return result \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/12931.py" "b/\354\247\200\353\257\274/week6/12931.py" new file mode 100644 index 0000000..1b0d655 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/12931.py" @@ -0,0 +1,15 @@ +# Level 1- 자릿수 더하기 +def solution(n): + answer = 0 + while (n > 0): + answer += n % 10 + n //= 10 + return answer + +# 다른 풀이 - 재귀 사용 +def sum_digit(number): + '''number의 각 자릿수를 더해서 return하세요''' + if number < 10: + return number + + return number%10 + sum_digit(number//10) From a01f4ac67c11056376dcc9c50944d8c50c1eb432 Mon Sep 17 00:00:00 2001 From: Jimin Yu <92876819+urjimyu@users.noreply.github.com> Date: Mon, 20 Nov 2023 00:09:22 +0900 Subject: [PATCH 2/2] solution: solved D1, D2 --- "\354\247\200\353\257\274/week6/D1/1545.py" | 17 +++++++ "\354\247\200\353\257\274/week6/D1/1933.py" | 21 ++++++++ "\354\247\200\353\257\274/week6/D1/1936.py" | 27 ++++++++++ "\354\247\200\353\257\274/week6/D1/1938.py" | 19 +++++++ "\354\247\200\353\257\274/week6/D1/2019.py" | 19 +++++++ "\354\247\200\353\257\274/week6/D1/2025.py" | 10 ++++ "\354\247\200\353\257\274/week6/D1/2027.py" | 2 + "\354\247\200\353\257\274/week6/D1/2029.py" | 21 ++++++++ "\354\247\200\353\257\274/week6/D1/2043.py" | 8 +++ "\354\247\200\353\257\274/week6/D1/2050.py" | 16 ++++++ "\354\247\200\353\257\274/week6/D1/2056.py" | 25 +++++++++ "\354\247\200\353\257\274/week6/D1/2058.py" | 16 ++++++ "\354\247\200\353\257\274/week6/D1/2063.py" | 15 ++++++ "\354\247\200\353\257\274/week6/D1/2068.py" | 15 ++++++ "\354\247\200\353\257\274/week6/D1/2070.py" | 14 +++++ "\354\247\200\353\257\274/week6/D1/2071.py" | 11 ++++ "\354\247\200\353\257\274/week6/D1/2072.py" | 24 +++++++++ "\354\247\200\353\257\274/week6/D1/input.txt" | 6 +++ "\354\247\200\353\257\274/week6/D2/1204.py" | 15 ++++++ "\354\247\200\353\257\274/week6/D2/1859.py" | 19 +++++++ "\354\247\200\353\257\274/week6/D2/1926.py" | 51 +++++++++++++++++++ "\354\247\200\353\257\274/week6/D2/1928.py" | 1 + "\354\247\200\353\257\274/week6/D2/1954.py" | 7 +++ "\354\247\200\353\257\274/week6/D2/1974.py" | 36 +++++++++++++ "\354\247\200\353\257\274/week6/D2/1984.py" | 17 +++++++ "\354\247\200\353\257\274/week6/D2/2001.py" | 19 +++++++ "\354\247\200\353\257\274/week6/D2/input.txt" | 4 ++ 27 files changed, 455 insertions(+) create mode 100644 "\354\247\200\353\257\274/week6/D1/1545.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/1933.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/1936.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/1938.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2019.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2025.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2027.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2029.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2043.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2050.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2056.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2058.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2063.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2068.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2070.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2071.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/2072.py" create mode 100644 "\354\247\200\353\257\274/week6/D1/input.txt" create mode 100644 "\354\247\200\353\257\274/week6/D2/1204.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1859.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1926.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1928.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1954.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1974.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/1984.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/2001.py" create mode 100644 "\354\247\200\353\257\274/week6/D2/input.txt" diff --git "a/\354\247\200\353\257\274/week6/D1/1545.py" "b/\354\247\200\353\257\274/week6/D1/1545.py" new file mode 100644 index 0000000..4e62b3c --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/1545.py" @@ -0,0 +1,17 @@ +import sys +sys.stdin = open("input.txt", "r") + +input_num = int(input()) +while (input_num >= 0): + print(input_num, end=' ') + input_num -= 1 + +# 다른 풀이 - 왜인지 이 풀이가 더 실행시간이 빠르다! +n = int(input()) +answer = [] +for i in range(n + 1): + answer.append(n) + n -= 1 + +for j in range(len(answer)): + print(answer[j], end=' ') \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/1933.py" "b/\354\247\200\353\257\274/week6/D1/1933.py" new file mode 100644 index 0000000..7371d08 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/1933.py" @@ -0,0 +1,21 @@ +import sys +sys.stdin = open("input.txt", "r") + +input_num = int(input()) +answers = [] + +i = 1 +while i <= input_num: + if input_num % i == 0: + answers.append(i) + i += 1 +for nums in answers: + print(nums, end=' ') + +# 다른 풀이 +n = int(input()) +answer = [] +for i in range(1,n+1) : + if n % i == 0 : + answer.append(i) +print(*answer) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/1936.py" "b/\354\247\200\353\257\274/week6/D1/1936.py" new file mode 100644 index 0000000..f0cb127 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/1936.py" @@ -0,0 +1,27 @@ +a, b = map(int, input().split()) +if (a == 1 and b == 2) or (a == 2 and b == 3) or (a==3 and b == 1): + print('B') +else: + print('A') + +# 다른 풀이 - 리스트 사용 +A, B = map(int, input().split()) +# 가위, 바위, 보 + # 1 2 3 +win = [0, 3, 1, 2] + +if A == B: + print('비김') +elif win[A] == B: + print('A') +else: + print('B') + +#다른 풀이 2 - 뺼셈 값으로 정답 반환 +A , B = map(int,input().split()) +answer = '' +if A-B == 1 or B-A == 2: + answer = 'A' +elif B-A == 1 or A-B == 2: + answer = 'B' +print(answer) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/1938.py" "b/\354\247\200\353\257\274/week6/D1/1938.py" new file mode 100644 index 0000000..fd000d5 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/1938.py" @@ -0,0 +1,19 @@ +import sys +sys.stdin = open("input.txt", "r") + +a, b = map(int, input().split()) +sum_result = a + b +minus_result = a - b +multiply_result = a * b +division_result = a // b +print(sum_result) +print(minus_result) +print(multiply_result) +print(division_result) + +# 다른 풀이 +a, b = map(int, input().split()) +print(a+b) +print(a-b) +print(a*b) +print(a//b) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2019.py" "b/\354\247\200\353\257\274/week6/D1/2019.py" new file mode 100644 index 0000000..fa717af --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2019.py" @@ -0,0 +1,19 @@ +import sys +sys.stdin = open("input.txt", "r") + + +total = int(input()) +init = 1 +print(1, end=' ') +for _ in range(1, total+1): + print(2*init, end=' ') + init = 2*init + +# 다른 풀이 - 더 깔끔하다 +N = int(input()) + +result = 1 + +for i in range(N + 1): + print(result, end=' ') + result *= 2 \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2025.py" "b/\354\247\200\353\257\274/week6/D1/2025.py" new file mode 100644 index 0000000..7e405c5 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2025.py" @@ -0,0 +1,10 @@ +rounds = int(input()) +sum = 0 +for i in range(1, rounds+1): + sum += i +print(sum) + +# 다른 풀이 - list 활용 +n = int(input()) +n1 = list(range(1, n+1)) +print(sum(n1)) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2027.py" "b/\354\247\200\353\257\274/week6/D1/2027.py" new file mode 100644 index 0000000..93e4a32 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2027.py" @@ -0,0 +1,2 @@ +for i in range(0, 5): + print('+'*i+'#'+'+'*(4 - i)) diff --git "a/\354\247\200\353\257\274/week6/D1/2029.py" "b/\354\247\200\353\257\274/week6/D1/2029.py" new file mode 100644 index 0000000..fcf8139 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2029.py" @@ -0,0 +1,21 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + a, b = map(int, input().split()) + div, mod = divmod(a, b) + print(f'#{test_case} {div} {mod}') + +# 다른 풀이 - 내장함수 없는 버전, 다른 출력 형태 +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + a, b = map(int, input().split()) + + quotient = a // b + remainder = a % b + + print('#{0} {1} {2}'.format(test_case, quotient, remainder)) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2043.py" "b/\354\247\200\353\257\274/week6/D1/2043.py" new file mode 100644 index 0000000..469ca44 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2043.py" @@ -0,0 +1,8 @@ +# P 비밀번호 +# K부터 1씩 증가 +P, K = map(int, input().split()) +print(P - K + 1) + +# 다른 풀이 - 예외 처리까지! +P, K = map(int, input().split()) +print(P-K+1 if P>K else P+1000-K) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2050.py" "b/\354\247\200\353\257\274/week6/D1/2050.py" new file mode 100644 index 0000000..b7eb19b --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2050.py" @@ -0,0 +1,16 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +strings = input() +strings = list(strings) +for i in range(len(strings)): + print(f'{ord(strings[i]) - 64}', end=' ') + +# 다른 풀이 - 아스키코드 값 활용 +if __name__ == '__main__': + alphabet = input() + alphabet = list(alphabet) + + for i in alphabet: + print(f"{ord(i) - 64}", end=' ') \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2056.py" "b/\354\247\200\353\257\274/week6/D1/2056.py" new file mode 100644 index 0000000..bcf262f --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2056.py" @@ -0,0 +1,25 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + raw_dates = list(input()) + year = ''.join(raw_dates[0:4]) + month = ''.join(raw_dates[4:6]) + date = ''.join(raw_dates[6:8]) + if int(year) < 0: + print(f"#{test_case} -1") + elif int(month) > 12 or int(month) < 1: + print(f"#{test_case} -1") + elif int(date) > 32 or int(date) < 1: + print(f"#{test_case} -1") + elif int(month) == 2 and int(date) > 28: + print(f"#{test_case} -1") + # if int(month) in [1,3,5,7,8,10,12]: 이렇게도 표현 가능! + elif (month == 4 or 6 or 9 or 11) and int(date) > 30: + print(f"#{test_case} -1") + else: + print(f"#{test_case} {year}/{month}/{date}") + diff --git "a/\354\247\200\353\257\274/week6/D1/2058.py" "b/\354\247\200\353\257\274/week6/D1/2058.py" new file mode 100644 index 0000000..f480a32 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2058.py" @@ -0,0 +1,16 @@ +# 각 자릿수 합 구하기 +inputs = int(input()) +sum = 0 +while (inputs > 0): + sum += inputs % 10 + inputs //= 10 +print(sum) + +# 다른 풀이 - 문자열 돌면서 숫자 변환해서 더하기 +# 첫줄 의미는 모르겠음.. +if __name__ == "__main__": + arr = input() + sum = 0 + for i in arr: + sum += int(i) + print(sum) diff --git "a/\354\247\200\353\257\274/week6/D1/2063.py" "b/\354\247\200\353\257\274/week6/D1/2063.py" new file mode 100644 index 0000000..98861a9 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2063.py" @@ -0,0 +1,15 @@ +import sys +sys.stdin = open("input.txt", "r") + +rounds = int(input()) +numbers = list(map(int, input().split())) +numbers = sorted(numbers) +print(numbers[(rounds + 1) // 2 - 1]) + +# 다른 풀이 - 그냥 //를 써버리면 된다. 어차피 인덱스는 1 뺴주니까 +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +a=list(map(int, input().split())) +a.sort() +mid=int(T//2) +print(a[mid]) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2068.py" "b/\354\247\200\353\257\274/week6/D1/2068.py" new file mode 100644 index 0000000..74f5251 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2068.py" @@ -0,0 +1,15 @@ +# import sys +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + numbers = map(int, input().split()) + print(f'#{test_case} {max(numbers)}') + +# 다른 풀이 - 다른 표현 방식 +T = int(input()) + +for test_case in range(1, T + 1): + nums = map(int, input().split()) + print("#%d %d" % (test_case, max(nums))) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2070.py" "b/\354\247\200\353\257\274/week6/D1/2070.py" new file mode 100644 index 0000000..b29b920 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2070.py" @@ -0,0 +1,14 @@ +# import sys +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + a, b = map(int, input().split()) + if a < b: + answer = '<' + elif a > b: + answer = '>' + else: + answer = '=' + print('#{0} {1}'.format(test_case, answer)) \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2071.py" "b/\354\247\200\353\257\274/week6/D1/2071.py" new file mode 100644 index 0000000..4039315 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2071.py" @@ -0,0 +1,11 @@ +# import sys +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + nums = list(map(int, input().split())) + sum = 0 + for num in nums: + sum += num + print(f'#{test_case} {round(sum / len(nums))}') \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/2072.py" "b/\354\247\200\353\257\274/week6/D1/2072.py" new file mode 100644 index 0000000..46cf257 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/2072.py" @@ -0,0 +1,24 @@ +# import sys +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + numbers = map(int, input().split()) + sum = 0 + for nums in numbers: + if nums % 2 != 0: + sum += nums + print(f'#{test_case} {sum}') + +# 다른 풀이 - array 활용, 실행시간 더 빠름 +n = int(input()) +array = [0] * n +for i in range(n): + data = list(map(int, input().split())) + for j in range(10): + if data[j] % 2 != 0: + array[i] += data[j] + +for i in range(n): + print(f"#{i + 1} {array[i]}") \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D1/input.txt" "b/\354\247\200\353\257\274/week6/D1/input.txt" new file mode 100644 index 0000000..f3c5e64 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D1/input.txt" @@ -0,0 +1,6 @@ +5 +22220228 +20150002 +01010101 +20140230 +11111111 \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D2/1204.py" "b/\354\247\200\353\257\274/week6/D2/1204.py" new file mode 100644 index 0000000..131b3b0 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1204.py" @@ -0,0 +1,15 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + rounds = int(input()) + scores = list(map(int, input().split())) + scores_set = list(set(scores)) + frequency = [] + for i in range(len(scores_set)): + frequency.append(scores.count(scores_set[i])) + max_index = frequency.index(max(frequency)) + print(f"#{rounds} {scores_set[max_index]}") diff --git "a/\354\247\200\353\257\274/week6/D2/1859.py" "b/\354\247\200\353\257\274/week6/D2/1859.py" new file mode 100644 index 0000000..eac7a6e --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1859.py" @@ -0,0 +1,19 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +# 배열 끝을 최댓값으로 설정, 앞으로 오면서 최댓값과의 차이를 비교(최댓값 갱신일 떄는 계산 안 함) + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + days = int(input()) + answer = 0 + costs = list(map(int, input().split())) + max_cost = costs[-1] + for i in range(days-2, -1, -1): + if max_cost <= costs[i]: + max_cost = costs[i] + else: + answer += max_cost - costs[i] + print(f"#{test_case} {answer}") diff --git "a/\354\247\200\353\257\274/week6/D2/1926.py" "b/\354\247\200\353\257\274/week6/D2/1926.py" new file mode 100644 index 0000000..1d5fd2d --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1926.py" @@ -0,0 +1,51 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") +# +# rounds = int(input()) +# for i in range(rounds): +# counts = 0 +# check = i + 1 +# answers = [] +# while check > 0: +# if check % 10 == 3 or check % 10 == 6 or check % 10 == 9: +# if answers and answers[-1] == "-": +# answers.append("-") +# else: +# answers.append(" -") +# elif check % 10 > 0: +# if answers and answers[-1] == '-': +# answers.append(f" {str(check % 10)} ") +# else: +# answers.append(f" {str(check % 10)}") +# check //= 10 +# answers.reverse() +# print(''.join(answers), end='') + +# 풀이 1 - count로 완전 간단히 +# i라는 숫자에 3 6 9 가 들어간 수 만큼 -출력, 띄어쓰기 없이 +# 그 외에는 일반 숫자 출력 + +T = int(input()) +for i in range(1, T+1): # 1 ~ 100 + + i = str(i) + clap = i.count('3') + i.count('6') + i.count('9') + + if clap == 0: + print(i, end=' ') + else: + print("-" * clap, end=' ') + +# 풀이 2 - list 사용 +N = int(input()) +clap = ['3', '6', '9'] + +for i in range(1, N+1): + count = 0 + for j in str(i): + if j in clap: + count += 1 + if count > 0: + i = '-' * count + print(i, end=' ') \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D2/1928.py" "b/\354\247\200\353\257\274/week6/D2/1928.py" new file mode 100644 index 0000000..c45aa02 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1928.py" @@ -0,0 +1 @@ +ord \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D2/1954.py" "b/\354\247\200\353\257\274/week6/D2/1954.py" new file mode 100644 index 0000000..64f26d3 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1954.py" @@ -0,0 +1,7 @@ +import sys +sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + 3 \ No newline at end of file diff --git "a/\354\247\200\353\257\274/week6/D2/1974.py" "b/\354\247\200\353\257\274/week6/D2/1974.py" new file mode 100644 index 0000000..1aaf400 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1974.py" @@ -0,0 +1,36 @@ +# import sys +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + answer = 0 + board = [list(map(int, input().split())) for _ in range(9)] + + for i in range(9): + # 가로 검사 + row_check = [0] * 10 + # 세로 검사 + col_check = [0] * 10 + for j in range(9): + row_check[board[i][j]] += 1 + col_check[board[j][i]] += 1 + # 중복 체크 + for k in range(1, 10): + if row_check[k] != 1: + answer = 0 + break + + if col_check[k] != 1: + answer = 0 + break + + # 3*3 검사 + for i in range(3): + for j in range(3): + square_check = [0]*10 + for k in range(3): + for l in range(3): + square_check[board[3i + k]] + +# print(f"#{test_case) {answer}" diff --git "a/\354\247\200\353\257\274/week6/D2/1984.py" "b/\354\247\200\353\257\274/week6/D2/1984.py" new file mode 100644 index 0000000..c34f244 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/1984.py" @@ -0,0 +1,17 @@ +# import sys +# +# sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + nums = list(map(int, input().split())) + min_num = min(nums) + max_num = max(nums) + for number in range(len(nums)): + if min_num in nums: + nums.remove(min_num) + if max_num in nums: + nums.remove(max_num) + answer = round(sum(nums) / len(nums)) + print(f"#{test_case} {answer}") diff --git "a/\354\247\200\353\257\274/week6/D2/2001.py" "b/\354\247\200\353\257\274/week6/D2/2001.py" new file mode 100644 index 0000000..8adcf55 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/2001.py" @@ -0,0 +1,19 @@ +import sys + +sys.stdin = open("input.txt", "r") + +T = int(input()) +# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. +for test_case in range(1, T + 1): + n, m = map(int, input().split()) + flies = [list(map(int, input().split())) for _ in range(n)] + max_sum = 0 + + for i in range(n - m + 1): + for j in range(n - m + 1): + current_sum = sum( + sum(flies[x][y] for y in range(j, j + m)) + for x in range(i, i + m) + ) + max_sum = max(max_sum, current_sum) + print(f"#{test_case} {max_sum}") diff --git "a/\354\247\200\353\257\274/week6/D2/input.txt" "b/\354\247\200\353\257\274/week6/D2/input.txt" new file mode 100644 index 0000000..6dbaa22 --- /dev/null +++ "b/\354\247\200\353\257\274/week6/D2/input.txt" @@ -0,0 +1,4 @@ +3 +3 17 1 39 8 41 2 32 99 2 +22 8 5 123 7 2 63 7 3 46 +6 63 2 3 58 76 21 33 8 1 \ No newline at end of file