https://www.hackerrank.com/contests/w3/challenges/the-love-letter-mystery

简单题。

#include <cstdlib>
#include <string>
#include <iostream> using namespace std; int main() {
int N;
cin >> N;
while (N--) {
string s;
cin >> s;
int count = 0;
int l = 0;
int r = s.size() - 1;
while (l < r) {
count += abs(s[l++] - s[r--]);
}
cout << count << endl;
}
return 0;
}

  

[hackerrank]The Love-Letter Mystery的更多相关文章

  1. 【HackerRank】The Love-Letter Mystery

    James找到了他的朋友Harry要给女朋友的情书.James很爱恶作剧,所以他决定要胡搞一下.他把信中的每个单字都变成了回文.对任何给定的字符串,他可以减少其中任何一个字符的值,例如'd'可以变成' ...

  2. [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  3. 17. Letter Combinations of a Phone Number

    题目: Given a digit string, return all possible letter combinations that the number could represent. A ...

  4. 什么是Unicode letter

    起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...

  5. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  6. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  7. No.017:Letter Combinations of a Phone Number

    问题: Given a digit string, return all possible letter combinations that the number could represent.A ...

  8. SCI/EI期刊投稿 Reply Letter 常用格式总结

    SCI/EI期刊投稿Reply Letter常用格式总结          整个论文投稿的过程中,会遇到各种问题,需要我们向主编询问或是回复.下面主要总结了responses to the comme ...

  9. 【leetcode】 Letter Combinations of a Phone Number(middle)

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

随机推荐

  1. 利用Apply的参数数组化来提高代码的优雅性,及高效性

    利用Apply的参数数组化来提高代码的优雅性,及高效性 Function.apply()在提升程序性能方面的技巧 我们先从Math.max()函数说起,Math.max后面可以接任意个参数,最后返回所 ...

  2. 解决Discuz“完善用户资料”任务不能完成的问题

    最近用 Discuz X3.2 搭建了个论坛,在测试过程中发现"完善用户资料"这个官方自带的任务有个Bug,将所有的资料都填写完成后,任务仍然无法完成,而且没有明确提示有哪些项目没 ...

  3. 仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表中的标识列指定显式值

    今天在处理数据时遇到这样一个错误 消息 8101,级别 16,状态 1,第 1 行 仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表'dbo.StockDetailValu ...

  4. mysql 配置主从

    1.选择2个ip,1个为主,1个为从:例:主:192.168.12.76 从:192.168.12.772.在192.168.12.76的my.cnf 配置master,添加如下:(红色为添加的内容) ...

  5. mapreduce 实现矩阵乘法

    import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs ...

  6. Android修改system只读权限

    在Root后的真机上使用adb remount命令不知道为什么不行. 但有些时候还是想向system文件夹下面写文件,例如把tcpdump工具放到/system/bin 下面,然后就可以直接使用tcp ...

  7. libcurl

    一.LibCurl基本编程框架 二.一些基本的函数 三.curl_easy_setopt函数部分选项介绍 四.curl_easy_perform 函数说明(error 状态码) 五.libcurl使用 ...

  8. C#基础原理拾遗——面试都爱问的委托和事件(纠正)

    这篇博客是我昨天写的,文中的观点有些问题,后经过网友留言和个人学习发现错误,原文还是保留,更改补在后面,不怕贻笑大方,唯恐误人子弟.不知道还能不能放在首页,让被误导的同学再被反误导一次. 一.原文 几 ...

  9. CentOS 6.5系统上安装MySQL数据库

    1.查看系统是否安装了MySQL      使用命令:      #rpm -qa | grep mysql 2.卸载已安装的MySQL       卸载mysql命令如下:        #rpm ...

  10. android手机推送视频到服务端

    项目需求,android手机向服务器推送视频.苦战几个星期终于实现,现记录下来以免以后忘记. 没做过Java,也没做过Android开发,只能现学现卖.在网上找了下搭建开发a  ndroid环境资料, ...