-
[1일 1백준 : 5622번] 다이얼Programming/백준 2021. 1. 25. 23:42
#include <iostream> #include <vector> // A ~ Z : 65 ~ 90 const int ConvertDialCharToNumber(char c) { int ANCII = c; if (ANCII <= (int)'C') return 2; else if (ANCII <= (int)'F') return 3; else if (ANCII <= (int)'I') return 4; else if (ANCII <= (int)'L') return 5; else if (ANCII <= (int)'O') return 6; else if (ANCII <= (int)'S') return 7; else if (ANCII <= (int)'V') return 8; else if (ANCII <= (int)'Z') return 9; } int main(void) { std::cin.tie(NULL); std::cout.tie(NULL); std::ios::sync_with_stdio(false); std::string words; std::vector<int> index; std::cin >> words; const int strSize = words.size(); index.reserve(strSize); for (size_t i = 0; i < strSize; i++) { index.emplace_back(ConvertDialCharToNumber(words[i])); } int timeSum = 0; for (size_t i = 0; i < index.size(); i++) { timeSum += index[i] + 1; } std::cout << timeSum << "\n"; return 0; }
5622번: 다이얼
첫째 줄에 알파벳 대문자로 이루어진 단어가 주어진다. 단어의 길이는 2보다 크거나 같고, 15보다 작거나 같다.
www.acmicpc.net
'Programming > 백준' 카테고리의 다른 글
[1일 1백준: 1316번] 그룹 단어 체커 (0) 2021.01.28 [1일 1백준 : 2941번] 크로아티아 알파벳 (0) 2021.01.26 [1일 1백준 : 2908번] 상수 (0) 2021.01.24 [1일 1백준 : 1152] 단어의 개수 (0) 2021.01.23 [1일1백준 : 1157번] 단어 공부 (0) 2021.01.23