跳到正文

题解

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

longyitongxue约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
2
题目
P13419

版本

  1. v1当前

题目传送门

主要思路

这道题,我们不难发现:需要的时间就是每个字母对应的数字 +1+1,然后求和即可。我们可以打表求出每个字母对应的数字,然后拿一个 ansans 累加这些字母对应的数字 +1+1,输出 ansans 即可。

AC code

C++
#include<iostream>
using namespace std;
int a[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        ans+=a[s[i]-'A']+1;
    }
    cout<<ans;
    return 0;
}
原文