From 2930949c11ddb2b6ab154e3c25344ce4357f287f Mon Sep 17 00:00:00 2001 From: keunho Date: Tue, 8 Oct 2024 00:14:35 +0900 Subject: [PATCH] =?UTF-8?q?2024-10-08=20=EC=95=BD=EC=88=98=EC=9D=98=20?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kokeunho/README.md | 1 + .../\352\265\254\355\230\204/3-kokeunho.py" | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 "kokeunho/\352\265\254\355\230\204/3-kokeunho.py" diff --git a/kokeunho/README.md b/kokeunho/README.md index ccb5b66..405d5a2 100644 --- a/kokeunho/README.md +++ b/kokeunho/README.md @@ -3,4 +3,5 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| | 1차시 | 2024.09.28 | 구현 | [킹](https://www.acmicpc.net/problem/1063) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/1) | +| 3차시 | 2024.10.08 | 구현 | [약수들의 합](https://www.acmicpc.net/problem/9506) | [#14] (https://github.com/AlgoLeadMe/AlgoLeadMe-12/pulls/14) | --- diff --git "a/kokeunho/\352\265\254\355\230\204/3-kokeunho.py" "b/kokeunho/\352\265\254\355\230\204/3-kokeunho.py" new file mode 100644 index 0000000..4a8a39c --- /dev/null +++ "b/kokeunho/\352\265\254\355\230\204/3-kokeunho.py" @@ -0,0 +1,30 @@ +while True: + n = int(input()) + if (n == -1): + break + else: + sum = 0 + factors = [] + + for i in range(1, n): + if (n % i == 0): + factors.append(i) + sum += i + + + if (sum == n): + print(f"{n} =", end=' ') + for i in range(len(factors)): + print(factors[i], end=' ') + if (i != (len(factors) - 1)): + print("+", end=' ') + else: + print(end='\n') + else: + print(f"{n} is NOT perfect.") + + + + + +