C++)
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
vector<int> v = { 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 };
string str;
cin >> str;
int ans = 0;
for (auto ch : str)
ans += v[ch - 'A'];
cout << ans;
return 0;
}
Python)
import sys
dict = {
"A":3, "B":3, "C":3,
"D":4, "E":4, "F":4,
"G":5, "H":5, "I":5,
"J":6, "K":6, "L":6,
"M":7, "N":7, "O":7,
"P":8, "Q":8, "R":8, "S":8,
"T":9, "U":9, "V":9,
"W":10, "X":10, "Y":10, "Z":10,
}
temp = sys.stdin().readline().rstrip()
ans = 0
for ch in temp:
ans += dict[ch]
print(ans)
'백준 1 > 기초' 카테고리의 다른 글
| [백준 2846] 오르막길 (C++/Python) (0) | 2020.12.05 |
|---|---|
| [백준 11399] ATM (C++/Python) (0) | 2020.12.05 |
| [백준 5585] 거스름돈 (C++/Python) (0) | 2020.12.05 |
| [백준 10797] 10부제 (C++/Python) (0) | 2020.12.05 |
| [백준 1193] 분수 찾기 (C++/Python) (0) | 2020.12.05 |