-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1110
More file actions
39 lines (29 loc) · 1.06 KB
/
BAEKJOON_1110
File metadata and controls
39 lines (29 loc) · 1.06 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//처음에 26을 입력받아.
int num = Integer.parseInt(br.readLine());
int resultNum = num;
int count = 1;
while (true) {
StringBuilder sb = new StringBuilder(); //여기서 새로운 인스턴스 할당이라 아래에서 append한것들이 사라진다.
int a = num / 10;
int b = num % 10;
String str1 = String.valueOf(b);
String str2 = String.valueOf((a + b) % 10);
sb.append(str1);
sb.append(str2);
String result = sb.toString();
if (resultNum == Integer.parseInt(result)) {
break;
} else {
count++;
num = Integer.parseInt(result);
}
}
System.out.println(count);
}
}