Algorithm
백준 2577번: 숫자의 개수
qlyh8
2018. 10. 15. 22:56
문제 출처: https://www.acmicpc.net/problem/2577
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int A = Integer.parseInt(reader.readLine()); int B = Integer.parseInt(reader.readLine()); int C = Integer.parseInt(reader.readLine()); int result = A*B*C; int arr[] = new int[10]; int count = String.valueOf(result).length(); int divide = (int) Math.pow(10, --count); for( ; divide>0 ; divide=divide/10){ arr[result/divide]++; result -= result/divide * divide; } for(int i=0 ; i<arr.length ; i++) System.out.println(arr[i]); } } | cs |