From 87f69c785299572f7a366a2ca5338779f6744d98 Mon Sep 17 00:00:00 2001 From: heeheejj Date: Sat, 14 Oct 2023 17:51:42 +0900 Subject: [PATCH] =?UTF-8?q?Week26=20PRG=2042842=20=EC=B9=B4=ED=8E=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week26/PRG_42842_\354\271\264\355\216\253.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "heeheej/week26/PRG_42842_\354\271\264\355\216\253.py" diff --git "a/heeheej/week26/PRG_42842_\354\271\264\355\216\253.py" "b/heeheej/week26/PRG_42842_\354\271\264\355\216\253.py" new file mode 100644 index 0000000..8230a77 --- /dev/null +++ "b/heeheej/week26/PRG_42842_\354\271\264\355\216\253.py" @@ -0,0 +1,13 @@ +# 카펫 +''' +yellow를 소인수분해해서, i와 yellow//i로 나타낼 수 있다. +brown == 2*(i+2) + 2*(yellow//i+2) - 4(겹치는부분) 이라는 식이 나오는데, +간소화하면 2*(i + yellow//i)+4 == brown이라 할 수 있다. +''' +def solution(brown, yellow): + answer = [] + N = int(yellow**(1/2))+1 + for i in range(1, N): + if yellow % i == 0 and 2*(i + yellow//i) + 4 == brown: + answer = [yellow//i+2, i+2] + return answer \ No newline at end of file