-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNo_2231.java
More file actions
41 lines (34 loc) · 1.04 KB
/
No_2231.java
File metadata and controls
41 lines (34 loc) · 1.04 KB
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
/*
Problem_2231_분해합
https://www.acmicpc.net/problem/2231
*/
import java.io.*;
public class No_2231 {
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 number = Integer.parseInt(br.readLine());
int digit = (int) (Math.log10(number) + 1);
int ctMax = number;
int ctMin = ctMax - (digit * 9);
for (int i = ctMin; i <= ctMax; i++) {
int decomposeSum = i;
int repeat = 0;
int temp = i;
while (digit != repeat) {
decomposeSum += temp % 10;
temp /= 10;
repeat++;
}
if (ctMax == decomposeSum) {
bw.write(i + "");
break;
} else if (i == ctMax) {
bw.write("0");
}
}
bw.flush();
bw.close();
br.close();
}
}