From c10f4519df638a06801c66c1a4c019cfc1f7fa92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E8=99=B9=E6=96=8C?= <13742852+yao-hongbin@user.noreply.gitee.com> Date: Wed, 22 Nov 2023 08:44:23 +0000 Subject: [PATCH] =?UTF-8?q?update=20problems/0030.=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E8=A7=A3=E5=8E=8B=E7=BC=A9.md.=20python=E8=A7=A3?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 姚虹斌 <13742852+yao-hongbin@user.noreply.gitee.com> --- ...62\350\247\243\345\216\213\347\274\251.md" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git "a/problems/0030.\345\255\227\347\254\246\344\270\262\350\247\243\345\216\213\347\274\251.md" "b/problems/0030.\345\255\227\347\254\246\344\270\262\350\247\243\345\216\213\347\274\251.md" index d0c96d9..b3dd095 100644 --- "a/problems/0030.\345\255\227\347\254\246\344\270\262\350\247\243\345\216\213\347\274\251.md" +++ "b/problems/0030.\345\255\227\347\254\246\344\270\262\350\247\243\345\216\213\347\274\251.md" @@ -123,6 +123,33 @@ public class Main { ## Python +s = input() +stack = [] +for i in range(len(s)): + + stack.append(s[i]) + if s[i] == ']': + stack.pop() + abc = [] + num = [] + flag=0 + while stack[-1]!='[': + x = stack.pop() + if x == '|': + flag = 1 + continue + if flag == 0: + abc.append(x) + + elif flag == 1: + num.append(x) + stack.pop() + stack.append(''.join(map(str,abc[::-1]))*int(''.join(map(str, num[::-1])))) +print(''.join(map(str,stack))) + + + + ## Go ## JS -- Gitee