From 7fc14695f89e8f37d0e8557737a13884d8456a52 Mon Sep 17 00:00:00 2001 From: zinnnn37 Date: Tue, 24 Feb 2026 23:52:40 +0900 Subject: [PATCH] =?UTF-8?q?[20260224]=20BOJ=20/=20G5=20/=20A=EC=99=80=20B?= =?UTF-8?q?=202=20/=20=EA=B9=80=EB=AF=BC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202602/24 BOJ G5 A\354\231\200 B 2.md" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "zinnnn37/202602/24 BOJ G5 A\354\231\200 B 2.md" diff --git "a/zinnnn37/202602/24 BOJ G5 A\354\231\200 B 2.md" "b/zinnnn37/202602/24 BOJ G5 A\354\231\200 B 2.md" new file mode 100644 index 00000000..67910bbe --- /dev/null +++ "b/zinnnn37/202602/24 BOJ G5 A\354\231\200 B 2.md" @@ -0,0 +1,50 @@ +```java +import java.io.*; + +public class BJ_12919_A와_B_2 { + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + private static int res; + private static String from, to; + + public static void main(String[] args) throws IOException { + init(); + sol(); + } + + private static void init() throws IOException { + from = br.readLine(); + to = br.readLine(); + } + + private static void sol() throws IOException { + bw.write(rec(to) + ""); + bw.flush(); + bw.close(); + br.close(); + } + + private static int rec(String to) throws IOException { + if (from.equals(to)) { + return 1; + } + + if (to.length() < from.length()) { + return 0; + } + + if (to.charAt(to.length() - 1) == 'A') { + res = rec(to.substring(0, to.length() - 1)); + } + + if (to.charAt(0) == 'B') { + StringBuilder tmp = new StringBuilder(to.substring(1)); + res = Math.max(res, rec(tmp.reverse().toString())); + } + return res; + } + +} +``` \ No newline at end of file