[BOJ] 5622: 닀이얼

ohhj1999Β·2021λ…„ 7μ›” 27일
0

[BOJ] Algorithm Solving

λͺ©λ‘ 보기
6/62
post-thumbnail

πŸ”’ 예제

>> WA

13

>> UNUCIC

36

πŸ”§ 풀이

1. string = sys.stdin.readline().rstrip()
2. dictionaryλ₯Ό ν™œμš©
	2.1 각 λ²ˆν˜Έλ§ˆλ‹€ μ•ŒνŒŒλ²³ 지정
3. μ‹œκ°„κ³„μ‚°
	3.1 1: 2초, 2:3초, 3:4초, ... ,9:10초, 0: 11초
	3.2 1κ³Ό 0은 μ•ŒνŒŒλ²³μ΄ μ—†μœΌλ―€λ‘œ μ œμ™Έ κ°€λŠ₯

πŸ”‘ λ‹΅μ•ˆ

import sys

num = {2: ['A', 'B', 'C'],
       3: ['D', 'E', 'F'],
       4: ['G', 'H', 'I'],
       5: ['J', 'K', 'L'],
       6: ['M', 'N', 'O'],
       7: ['P', 'Q', 'R', 'S'],
       8: ['T', 'U', 'V'],
       9: ['W', 'X', 'Y', 'Z']}

string = sys.stdin.readline().rstrip()
time = 0
for i in range(len(string)):
    for n in num:
        if string[i] in num[n]:
            time += (n + 1)
print(time)

πŸ’‘ κ°œλ…

### dictionary
# key: value 둜 이루어진 μžλ£Œν˜•
# dict[key] = value
thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
print(thisdict["brand"])	# Ford

0개의 λŒ“κΈ€