Algorithm
백준 5622번: 다이얼
qlyh8
2018. 10. 20. 02:58
문제출처: https://www.acmicpc.net/problem/5622
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String input = reader.readLine(); // 2:ABC, 3:DEF, 4:GHI, 5:JKL, 6:MNO, 7:PQRS, 8:TUV, 9:WXYZ (1초씩 더 걸림) int[] arr = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10}; int result = 0; for(int i=0 ; i<input.length() ; i++) result += arr[input.charAt(i)-'A']; System.out.println(result); } } | cs |