Home [BOJ 2092] KMP는 왜 KMP일까?
Post
Cancel

[BOJ 2092] KMP는 왜 KMP일까?

KMP는 왜 KMP일까? (2902번)

https://www.acmicpc.net/problem/2902

풀이방법

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        
        StringBuilder sb = new StringBuilder();
        sb.append(str.charAt(0));
        for(int i=1; i<str.length(); i++) {
            if (str.charAt(i) == '-') {
                sb.append(str.charAt(i+1));
            }
        }
        
        System.out.println(sb);
    }
}

This post is licensed under CC BY 4.0 by the author.

[BOJ 4375] 1

[BOJ 17427] 약수의 합 2

Comments powered by Disqus.