-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagicalElevator_2.java
More file actions
37 lines (26 loc) · 898 Bytes
/
Copy pathMagicalElevator_2.java
File metadata and controls
37 lines (26 loc) · 898 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
36
37
package Programmers;
import java.util.Scanner;
public class MagicalElevator_2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
int n = Integer.parseInt(str);
int digit = str.length(); // 자리수
int center = Integer.parseInt("5".repeat(digit));
int centerValue = 0;
if (digit == 1) centerValue = 5;
else if (digit == 2) centerValue = 10;
else if (digit > 2) {
centerValue = 10 + 4 * (digit - 2);
}
int result = str.chars()
.map(a -> a - 48)
.map(a -> Math.abs(5 - a))
.sum();
int result2 = centerValue - result;
System.out.println(center);
System.out.println(centerValue);
System.out.println(result);
System.out.println(result2);
}
}