반응형
🔺 문제
🔺 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int[] A = new int[10];
for(int i = 0 ; i < str.length() ; i++) {
int tmp = str.charAt(i) - '0';
if(tmp == 6) A[9]++;
else A[tmp]++;
}
int max = 0;
for(int i = 0 ; i < 9 ; i++) {
max = Math.max(max, A[i]);
}
int nine = A[9] / 2;
if(A[9] % 2 == 1) nine++;
max = Math.max(max, nine);
System.out.println(max);
}
}
|
cs |
✅ 해결 아이디어
✔ 구현
- 6,9를 합쳐 반으로 나누는데, 이 때 합이 홀수일 때는 +1 함 (Line 24)
💥 유의사항
• 6과 9 ⇨ 같은 수 취급
🔺 다른 풀이들
- 이게 좀 더 깔끔하심!
💬 느낀 점
우당탕탕...
1회독 | 2회독 | 3회독 | 4회독 | 5회독 |
V |
(참고)
반응형
'코테 > 백준' 카테고리의 다른 글
[백준/JAVA] 2075번: N번째 큰 수 (0) | 2023.08.14 |
---|---|
[백준/JAVA] 17266번: 어두운 굴다리 (0) | 2023.08.13 |
[백준/JAVA] 2512번: 예산 (0) | 2023.08.10 |
[백준/JAVA] 2607번: 비슷한 단어 (0) | 2023.08.10 |
[백준/JAVA] 10819번: 차이를 최대로 (0) | 2023.08.08 |