File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.util.* ;
3+ import java.io.* ;
4+
5+ public class boj12904 {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static StringTokenizer st;
8+
9+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
10+
11+ static String S ;
12+ public static void main(String [] args) throws Exception {
13+ nextLine();
14+ S = st. nextToken();
15+ nextLine();
16+ String T = st. nextToken();
17+ System . out. println(find(T ));
18+ }
19+
20+ static int find(String curr) {
21+ int len = curr. length();
22+ if (S . equals(curr)) return 1 ;
23+ else {
24+ if (len <= 1 ) return 0 ;
25+ }
26+ if (curr. charAt(len- 1 ) == ' B' ) {
27+ StringBuilder sb = new StringBuilder (curr. substring(0 , len - 1 ));
28+ return find(sb. reverse(). toString());
29+ } else if (curr. charAt(len- 1 ) == ' A' ) {
30+ return find(curr. substring(0 , len - 1 ));
31+ }
32+ return 0 ;
33+ }
34+ }
35+ ```
You can’t perform that action at this time.
0 commit comments