• 문제 링크
2577번: 숫자의 개수
첫째 줄에 A, 둘째 줄에 B, 셋째 줄에 C가 주어진다. A, B, C는 모두 100보다 크거나 같고, 1,000보다 작은 자연수이다.
www.acmicpc.net
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
int n = read() * read() * read();
int[] arr = new int[10];
do arr[n % 10]++; while ((n /= 10) > 0);
for (int i : arr) sb.append(i).append("\n");
bw.write(sb.toString());
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 1440 타임머신 - Brute Force / Java (0) | 2024.03.23 |
---|---|
[백준] 8958 OX퀴즈 - Implementation / Java (0) | 2024.03.22 |
[백준] 2675 문자열 반복 - Implementation / Java (0) | 2024.03.20 |
[백준] 10809 알파벳 찾기 - Implementation / Java (0) | 2024.03.19 |
[백준] 1110 더하기 사이클 - Implementation / Java (0) | 2024.03.18 |
댓글