跳到正文

题解

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

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

文章信息

发布
2025年7月24日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟
题目
P13419

版本

  1. v1当前

前置准备

模拟。

题目解析与注意事项

解题关键:

  • 每个字母对应一个数字。

  • 拨号时间规则:对于数字 aa 耗时为 a+1a+1 秒。

代码

C++
#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;
} 

结束语

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

原文