跳到正文

题解

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

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

文章信息

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

版本

  1. v1当前

P13419 [COCI 2012/2013 #6] BAKA

~~(这是一道代码实现十分简单的题目,就不废话,直接干吧!)

更具题目要求,我们只需要把需要拨的字母在拨号盘上对应的数字加上 11 就可以算出拨这个字母所需要的时间,再将所有字母的所需要时间累加起来就可以算出答案。

话不多说,直接上代码:

C++
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <set>
using namespace std;
int ans = 0;
string s;
int a[30] = {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(0), cin.tie(0),
		cout.tie(0);  // 输入输出加速语句,可以不加。
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		ans += a[s[i] - 'A'] + 1;  // 字母在拨号盘上对应数字加1算出所需要的时间
	}
	cout << ans << endl;  // 输出答案
	return 0;
}

求管理大大给个通过!\tiny求管理大大给个通过!

原文