λ¬Έμ
https://www.acmicpc.net/problem/2941
νμ΄
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class ν¬λ‘μν°μμνλ²³ {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
byte[] byteArr = br.readLine().getBytes();
int count = 0;
for (int i = 0; i < byteArr.length; i++) {
if (byteArr[i] == 'c' && i < byteArr.length - 1) {
if (byteArr[i + 1] == '=' || byteArr[i + 1] == '-') {
i++;
}
} else if (byteArr[i] == 'd' && i < byteArr.length - 1) {
if (byteArr[i + 1] == 'z' && i < byteArr.length - 2) {
if (byteArr[i + 2] == '=') {
i += 2;
}
} else if (byteArr[i + 1] == '-') {
i++;
}
} else if (byteArr[i] == 'l' && i < byteArr.length - 1) {
if (byteArr[i + 1] == 'j') {
i++;
}
} else if (byteArr[i] == 'n' && i < byteArr.length - 1) {
if (byteArr[i + 1] == 'j') {
i++;
}
} else if (byteArr[i] == 's' && i < byteArr.length - 1) {
if (byteArr[i + 1] == '=') {
i++;
}
} else if (byteArr[i] == 'z' && i < byteArr.length - 1) {
if (byteArr[i + 1] == '=') {
i++;
}
}
count++;
}
System.out.println(count);
}
}
λ¬Έμ λ λ¨μν κ²½μ°μ μλ§ μ λλκ³ λ°°μ΄μ ν¬κΈ°λ§ μ£Όμν΄μ£Όλ©΄ λλ€.
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Java] [Silver4] 10866_λ± (1) | 2024.01.10 |
---|---|
π© [λ°±μ€] [Java] [Silver2] 1260λ²_DFSμ BFS (0) | 2024.01.08 |
π© [λ°±μ€] [Java] [Silver5] 1316λ²_κ·Έλ£Ή λ¨μ΄ 체컀 (1) | 2023.12.08 |
π© [λ°±μ€] [Java] [Silver5] 4673λ²_μ ν λλ² (0) | 2023.12.07 |
π© [λ°±μ€] [Python] [Silver1] 13335λ²_νΈλ (0) | 2023.06.29 |