Skip to content

Commit ed80d37

Browse files
authored
[20251006] BOJ / G5 / 종이 접기
1 parent 2c7de6a commit ed80d37

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main{
6+
static boolean check(String s){
7+
if(s.length() == 1)
8+
return true;
9+
int mid=s.length() / 2;
10+
for(int i=0; i < mid; i++){
11+
if(s.charAt(i) == s.charAt(s.length()- 1 - i))
12+
return false;
13+
}
14+
return check(s.substring(0, mid)) && check(s.substring(mid+ 1));
15+
}
16+
17+
public static void main(String[] args)throws IOException{
18+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
19+
int t = Integer.parseInt(br.readLine());
20+
StringBuilder sb=new StringBuilder();
21+
while(t-->0){
22+
sb.append(check(br.readLine() ) ? "YES\n" : "NO\n");
23+
}
24+
25+
System.out.print(sb.toString());
26+
br.close();
27+
}
28+
}
29+
30+
```

0 commit comments

Comments
 (0)