본문 바로가기

백준

5622 다이얼

할머니 1이랑 0은 안 누르시나...? 고민하다가 제출했는데 맞았다

 

1이랑 0은 표현할 알파벳이 없어서 안 들어오나 보다

 

 

 

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>

#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()

using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;

using namespace std;

int main()
{
    string str;
    cin >> str;

    int ans = 0;
    for (int i = 0; i < str.size(); i++)
    {
        if (str[i] == 'A' || str[i] == 'B' || str[i] == 'C')
            ans += 3;
        if (str[i] == 'D' || str[i] == 'E' || str[i] == 'F')
            ans += 4;
        if (str[i] == 'G' || str[i] == 'H' || str[i] == 'I')
            ans += 5;
        if (str[i] == 'J' || str[i] == 'K' || str[i] == 'L')
            ans += 6;
        if (str[i] == 'M' || str[i] == 'N' || str[i] == 'O')
            ans += 7;
        if (str[i] == 'P' || str[i] == 'Q' || str[i] == 'R' || str[i] == 'S')
            ans += 8;
        if (str[i] == 'T' || str[i] == 'U' || str[i] == 'V')
            ans += 9;
        if (str[i] == 'W' || str[i] == 'X' || str[i] == 'Y' || str[i] == 'Z')
            ans += 10;
    }

    cout << ans << endl;
    return 0;
}

'백준' 카테고리의 다른 글

2563 색종이  (0) 2020.09.28
18221 교수님 저는 취업할래요  (0) 2020.09.28
1166 선물  (0) 2020.09.26
11949 번호표 교환  (0) 2020.09.26
15993 1, 2, 3 더하기 8  (0) 2020.09.26