[JAVA | 백준 5622] 다이얼
· 테크· Java
Java
백준 5622번 문항 www.acmicpc.net/problem/5622
풀이
Scanner 보다 처리속도가 빠른 Buffered Stream 을 사용해서 코드를 작성했다.
영문자에 해당하는 값이 처리되는 속도(전화 거는데 걸리는 속도)를 반환하여 전체 소요시간을 계산한다.
|
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.io.*;
public class string_5622 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String a = br.readLine();
int len = a.length();
int time = 0;
int result = 0;
for (int i=0; i<len; i++) {
char ch = a.charAt(i);
if(65<=ch&&ch<=67) time = 3;
else if(68<=ch&&ch<=70) time = 4;
else if(71<=ch&&ch<=73) time = 5;
else if(74<=ch&&ch<=76) time = 6;
else if(77<=ch&&ch<=79) time = 7;
else if(80<=ch&&ch<=83) time = 8;
else if(84<=ch&&ch<=86) time = 9;
else if(87<=ch&&ch<=90) time = 10;
result += time;
}
System.out.println(result);
br.close();
}
}
|
cs |
Comments
No comments yet. Be the first!
319 posts in 테크
- 368Supabase 프로젝트 복사하기 (Restore to a New Project)NEW
- 341Migrating from Permanent Access Tokens to Token Exchange — Why Order Matters
- 326Startup & Product Glossary: Terms Every Solo Founder Should Know
- 325Context Management — How I Do It Now
- 324Claude Code Routines vs Cowork Schedule — What's the Difference?
1–5 / 319