BOJ/String
[BOJ] 1475번 방 번호
J_Jayce
2019. 8. 22. 13:35
문제
https://www.acmicpc.net/problem/1475
1475번: 방 번호
첫째 줄에 다솜이의 방 번호 N이 주어진다. N은 1,000,000보다 작거나 같은 자연수 또는 0이다.
www.acmicpc.net
풀이
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
30
31
32
|
public class Main {
static Scanner scan = new Scanner(System.in);
static int Num,cnt=1;
static int[] chk;
static void solution() {
int Max = -1;
Num = scan.nextInt();
chk = new int[10];
do {
chk[Num%10]++;
Num/=10;
}
while(Num!=0);
for(int i=0;i<10;i++) {
if(i!=6 && i!=9)
Max = Math.max(Max, chk[i]);
}
System.out.println(Max);
}
public static void main(String[] args) {
solution();
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|