반응형
단계별로 풀기에서 단계4까지 중 가장 어려웠던 문제.
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
|
/*
* Author : Jeonghun Cho
* Date : December 3, 2019
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String str = br.readLine();
if(str.length() == 1) {
str = "0"+str;
}
String answer = str;
int cnt = 0;
while(true) {
int tens = str.charAt(0)-48;
int units = str.charAt(1)-48;
int result = tens+units;
if(result >= 10) {
result %= 10;
}
str = units+""+result;
cnt++;
if(str.equals(answer)) {
break;
}
}
}
}
Colored by Color Scripter
|
반응형
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 2562 최댓값 (Java) (0) | 2019.12.03 |
---|---|
[백준] 10816 최소, 최대 (Java) (0) | 2019.12.03 |
[백준] 10951 A + B - 4 (Java) (0) | 2019.12.02 |
[백준] 10952 A + b - 5 (Java) (0) | 2019.12.02 |
[백준] 10871 X보다 작은 수 (Java) (0) | 2019.12.02 |