반응형
Notice
Recent Posts
Recent Comments
Link
지구정복
[문자열] 백준 - Pen Pineapple Apple Pen 본문
728x90
반응형
-자바
package dp;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class PenPineapple {
private static BufferedWriter bw =
new BufferedWriter( new OutputStreamWriter(System.out));
private static int n;
private static String s, ans;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt( br.readLine() );
s = br.readLine();
ans = s.replaceAll( "pPAp", "1" ).replaceAll( "[^0-9]", "" );
bw.write( ans.length() + "\n" );
bw.flush();
bw.close();
br.close();
}
}
728x90
반응형
'데이터 엔지니어링 정복 > Algorithm' 카테고리의 다른 글
[DP] 백준 - 퇴사2 (0) | 2021.07.16 |
---|---|
[DP] 백준 - 설탕배달 (0) | 2021.07.15 |
[DP] 백준 - 피보나치 수 5 (0) | 2021.07.15 |
[DP] 백준 - 제곱수의 합 (0) | 2021.07.15 |
[DP] 백준 - 가장 긴 증가하는 수열 (0) | 2021.07.15 |
Comments