Algorithm 문제풀이/greedy
[BOJ] 백준 10610 - 30 (JAVA)
cjsong
2019. 6. 19. 22:06
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
33
34
35
36
37
38
39
40
41
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class Main10610_30{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String num = br.readLine();
int[] arr = new int[10];
for (int i = 0; i < num.length(); i++) {
arr[num.charAt(i)-'0']++;
}
StringBuilder sb = new StringBuilder();
int sum = 0;
if(arr[0] == 0) { //30으로 나누는 수라서 처음에 0이 안들어있으면 나눌 수 없으니깐 -1 출력
}else {
for (int i = 0; i < 10; i++) {
sum += arr[i]*i;
}
if(sum%3==0) { //3으로 나눠서 나머지가 0이면 값 처리 아니면 -1
for (int i = 9; i >= 0; i--) {
for (int j = 0; j < arr[i]; j++) {
}
}
}else {
}
}
System.out.println(sb);
}//main
}// end of class
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs |