From 4df2c1ad5d29e53a265e95fccd2ba452bfde88a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A0=9C=ED=9D=AC?= <103947888+pinkkj@users.noreply.github.com> Date: Fri, 28 Nov 2025 00:11:34 +0900 Subject: [PATCH] =?UTF-8?q?251127=20:=20[BOJ=2017214]=20=EB=8B=A4=ED=95=AD?= =?UTF-8?q?=20=ED=95=A8=EC=88=98=EC=9D=98=20=EC=A0=81=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _jehui/17214.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 _jehui/17214.py diff --git a/_jehui/17214.py b/_jehui/17214.py new file mode 100644 index 00000000..19d9badc --- /dev/null +++ b/_jehui/17214.py @@ -0,0 +1,36 @@ +import collections + +eq = input() + +def integrate(term): + t_dic = collections.Counter(term) + a=term[:len(term)-t_dic["x"]] + a = int(a) if len(a) != 0 else 1 + + b = str(a//(t_dic["x"]+1)) + result = b + "x" * (t_dic["x"]+1) if b != "1" else "x" * (t_dic["x"]+1) + return result + +op = ["+","-"] +if eq[0] in op: + answer = eq[0] + start = 1 + end = 1 +else : + answer = "" + start = 0 + end = 0 +if eq[start] == "0": + print("W") +else: + while end < len(eq): + if eq[end] not in op: + end += 1 + else: + answer += integrate(eq[start:end]) + #부호 + answer += eq[end] + start = end + 1 + end += 1 + answer += integrate(eq[start:])+"+W" + print(answer)