From d2477b1041c68b974a09740ea18e9cc3ad4b61ec Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sun, 12 Oct 2025 19:35:55 +0900 Subject: [PATCH] =?UTF-8?q?[20251012]=20BOJ=20/=20G3=20/=20=EA=B7=B8?= =?UTF-8?q?=EB=9E=A8=ED=8C=AC=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...J \352\267\270\353\236\250\355\214\254.md" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "0224LJH/202510/12 BOJ \352\267\270\353\236\250\355\214\254.md" diff --git "a/0224LJH/202510/12 BOJ \352\267\270\353\236\250\355\214\254.md" "b/0224LJH/202510/12 BOJ \352\267\270\353\236\250\355\214\254.md" new file mode 100644 index 00000000..5c7e84be --- /dev/null +++ "b/0224LJH/202510/12 BOJ \352\267\270\353\236\250\355\214\254.md" @@ -0,0 +1,76 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class Main { + + static final char START = 'A'; + static final char FINAL = 'Z'; + static String input; + static long ans; + + public static void main(String[] args) throws NumberFormatException, IOException { + init(); + process(); + print(); + } + + + + public static void init() throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + input = br.readLine(); + } + + public static void process() throws IOException { + int idx = 0; + int size = input.length(); + long cnt = 0; + long serialStart = 0; + + while(idx < size -1 ){ + if (input.charAt(idx) == START) { + serialStart++; + idx++; + } + else if (input.charAt(idx) == START + 1 && serialStart != 0) { + boolean isGramPen = false; + char target = 'B'; + long serialLast = 1; + + + while(idx < size) { + if (input.charAt(idx) == target) { + if (target == 'Z') serialLast++; + + } else if(target != 'Z' && input.charAt(idx) == target+1) { + target++; + if (target == 'Z') isGramPen = true; + } else { + break; + } + idx++; + } + + if (isGramPen) cnt += serialStart*serialLast; + serialStart = 0; + } else { + idx++; + serialStart = 0; + } + + } + ans = cnt; + } + + + + + public static void print() { + System.out.print(ans); + + } +} +```