forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbac2231_분해합.java
More file actions
35 lines (29 loc) · 801 Bytes
/
bac2231_분해합.java
File metadata and controls
35 lines (29 loc) · 801 Bytes
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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
class bac2231_분해합 {
static Scanner sc = new Scanner(System.in);
static int answer = 0;
public static void main(String[] args) {
int input = sc.nextInt();
solution(input);
System.out.println(answer);
}
public static void solution(int input)
{
for(int i =0; i<input; i++)
{
String buffer = "" +i;
int dst_value_i = 0;
for(int j=0; j<buffer.length(); j++)
{
dst_value_i += Integer.parseInt("" + buffer.charAt(j));
}
dst_value_i += i;
if(dst_value_i == input) {
answer = i;
break;
}
}
}
}