📝 문제
🔑 풀이 과정
정수 A, B, C의 범위가 100보다 크거나 같고, 1000보다 작으므로 세 숫자의 곱이 int형의 범위를 초과하지 않는다.
while문 조건만 잘 잡아주면 아주 쉬운 문제.
10으로 나눠주는걸 반복하다보면 어느순간 몫이 0이 된다.(모든 자리를 순회한 것)
이때 while문을 탈출해 주면 된다.
🔓 답안
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int num1 = Integer.parseInt(br.readLine());
int num2 = Integer.parseInt(br.readLine());
int num3 = Integer.parseInt(br.readLine());
int result = num1 * num2 * num3;
int[] arr = new int[10];
while(result != 0){
arr[result % 10]++;
result = result / 10;
}
for(int i = 0; i < 10; i++){
bw.write(arr[i] + "\n");
}
bw.flush();
bw.close();
}
}
'PS > Baekjoon' 카테고리의 다른 글
[Baekjoon] 3052 - 나머지 (0) | 2022.12.31 |
---|---|
[Baekjoon] 2908 - 상수 (0) | 2022.12.30 |
[Baekjoon] 1157 - 단어 공부 (0) | 2022.12.28 |
[Baekjoon] 1152 - 단어의 개수 (0) | 2022.12.27 |
[Baekjoon] 10870 - 피보나치 수 5 (0) | 2022.12.26 |
댓글