From 0206dbdb403d28c252dca4fb5c622011ed85dd1e Mon Sep 17 00:00:00 2001 From: Muhun Kim Date: Mon, 15 Jun 2020 14:59:26 +0900 Subject: [PATCH 1/3] Solved 17174 --- problems/P17174.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 problems/P17174.py diff --git a/problems/P17174.py b/problems/P17174.py new file mode 100644 index 0000000..88f98b5 --- /dev/null +++ b/problems/P17174.py @@ -0,0 +1,16 @@ +def solution(amount: int, groupTO: int): + count = amount + + while amount > 0: + amount //= groupTO + count += amount + return count + + +def test_solution(): + assert solution(13, 10) == 14 + assert solution(100, 8) == 113 + + +if __name__ == "__main__": + print(solution(*map(int, input().split()))) From 23ec4b4903b8b56069856bce3a4d9ba521ede5bc Mon Sep 17 00:00:00 2001 From: Muhun Kim Date: Mon, 15 Jun 2020 15:05:54 +0900 Subject: [PATCH 2/3] WIP 12781 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 두 선분의 교차 여부를 확인하는 문제다. 아래 자료를 그대로 재구현해서 백준에 제출하니 80% 정도 넘겨가면서 틀렸다. 참고 자료 : https://gaussian37.github.io/math-algorithm-line_intersection/ --- problems/P12781.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 problems/P12781.py diff --git a/problems/P12781.py b/problems/P12781.py new file mode 100644 index 0000000..40038d7 --- /dev/null +++ b/problems/P12781.py @@ -0,0 +1,41 @@ +def ccw(first: list, second: list, third: list): + cross_porduct = (second[0] - first[0])*(third[1] - first[1]) - \ + (third[0] - first[0])*(second[1] - first[1]) + if cross_porduct > 0: + return 1 + if cross_porduct < 0: + return -1 + return 0 + + +def comparator(left: list, right: list): + if left[0] == right[0]: + return left[1] <= right[1] + return left[0] <= right[1] + + +def solution(first: list, second: list): + first_scope = ccw(*first, second[0]) * ccw(*first, second[1]) + second_scope = ccw(*second, first[0]) * ccw(*second, first[1]) + + if (first_scope == 0 and second_scope == 0): + if comparator(first[1], first[0]): + first[1], second[0] = first[0], second[1] + if comparator(second[1], second[0]): + second[1], second[0] = second[0], second[1] + return comparator(second[0], first[1]) and comparator(first[0], second[1]) + + return first_scope <= 0 and second_scope <= 0 + + +def test_solution(): + assert solution([[0, 0], [6, 2]], [[5, -4], [2, 2]]) == True + assert solution([[-1, -5], [6, 3]], [[1, 10], [-4, -1]]) == False + + +if __name__ == "__main__": + lines = list(map(int, input().split())) + if solution([lines[:2], lines[2:4]], [lines[4:6], lines[6:]]): + print(1) + else: + print(0) From 55ba2e5c994e38d8988c8a20353509e217092672 Mon Sep 17 00:00:00 2001 From: Muhun Kim Date: Tue, 16 Jun 2020 17:25:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EB=91=90=20=EC=84=A0=EC=9D=B4=20=EA=B2=B9?= =?UTF-8?q?=EC=B9=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EB=A5=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/P12781.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/problems/P12781.py b/problems/P12781.py index 40038d7..4b8ad0c 100644 --- a/problems/P12781.py +++ b/problems/P12781.py @@ -18,12 +18,8 @@ def solution(first: list, second: list): first_scope = ccw(*first, second[0]) * ccw(*first, second[1]) second_scope = ccw(*second, first[0]) * ccw(*second, first[1]) - if (first_scope == 0 and second_scope == 0): - if comparator(first[1], first[0]): - first[1], second[0] = first[0], second[1] - if comparator(second[1], second[0]): - second[1], second[0] = second[0], second[1] - return comparator(second[0], first[1]) and comparator(first[0], second[1]) + if first_scope == 0 and second_scope == 0: + return False return first_scope <= 0 and second_scope <= 0