题解:P13419 [COCI 2012/2013 #6] BAKA

· · 题解

前置准备

模拟。

题目解析与注意事项

解题关键:

代码

#include<bits/stdc++.h>
using namespace std;
#define int long long
string ch;
int sum=0;
int f(char x){
    if(x=='A'||x=='B'||x=='C'){
        return 3;
    }
    if(x=='D'||x=='E'||x=='F'){
        return 4;
    }
    if(x=='G'||x=='H'||x=='I'){
        return 5;
    }
    if(x=='J'||x=='K'||x=='L'){
        return 6;
    }
    if(x=='M'||x=='N'||x=='O'){
        return 7;
    }
    if(x=='P'||x=='Q'||x=='R'||x=='S'){
        return 8;
    }
    if(x=='T'||x=='U'||x=='V'){
        return 9;
    }
    if(x=='W'||x=='X'||x=='Y'||x=='Z'){
        return 10;
    }
}
signed main(){
    cin>>ch;
    for(int i=0;i<ch.size();i++){
        sum=sum+f(ch[i]);
    }
    cout<<sum;
    return 0;
} 

结束语

欢迎大家为本题解提出宝贵意见!