CodeForces 731 A.Night at the Museum(水~)
来源:互联网 发布:韶关市网络问政门户 编辑:程序博客网 时间:2024/05/16 13:53
Description
一个键盘如下:
问至少转多少格可以打出串s
Input
一个字符串s,串长不超过100
Output
输出打出s最少需要转多少格
Sample Input
zeus
Sample Output
18
Solution
简单题,每次顺时针转和逆时针转取个较小值
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 111char s[maxn]; int main(){ while(~scanf("%s",s)) { int n=strlen(s),ans=0,pre=0; for(int i=0;i<n;i++) { int t=s[i]-'a'; ans+=min(abs(t-pre),26-abs(t-pre)); pre=t; } printf("%d\n",ans); } return 0;}
0 0
- CodeForces 731 A.Night at the Museum(水~)
- CodeForces 731A Night at the Museum
- CodeForces 731A Night at the Museum
- CodeForces 731A-Night at the Museum
- codeforces 731A Night at the Museum
- CodeForces 731A Night at the Museum
- 【87.65%】【codeforces 731A】Night at the Museum
- CodeForces 731A 之 Night at the Museum
- CodeForces 731A - Night at the Museum(模拟)
- Codeforce 731A. Night at the Museum
- CodeForces 731A Night at the Museum(博物馆循环的单词表)
- A. Night at the Museum
- Codeforces Round #376 (Div. 2) A. Night at the Museum
- Codeforces Round #376 (Div. 2) A. Night at the Museum
- 【Codeforces Round #376 (Div. 2)】 Codeforces 731A Night at the Museum
- Codeforces Round #376 (Div. 2) A. Night at the Museum(水题)
- Night at the Museum(水题)
- Codeforces Round #376 (Div. 2) A. Night at the Museum【模拟】
- 牛客网 不等式数列
- 医院CRM是什么?医院CRM能做什么?
- bitset
- Intellij IDEA svn的使用
- python—命名规范
- CodeForces 731 A.Night at the Museum(水~)
- 正则表达式
- MailBee.NET Objects发送电子邮件(SMTP)教程二:SMTP认证
- ConcurrentHashMap详解
- SecureCRT中改变背景色和文字颜色
- react-native-vector-icons 图标库的使用
- 简明扼要的反射入门教程
- JavaEE学习笔记--JavaScript(1)
- iOS动画篇:UIView动画