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. sql server 中 bigint 和 datetime 性能比较

    -- 创建表 create table Test_tbl ( ID varchar(40) primary key nonclustered, IntCol int, DateCol datetime ...

  2. 使用自定义的item、Adapter和AsyncTask、第三方开源框架PullToRefresh联合使用实现自定义的下拉列表(从网络加载图片显示在item中的ImageView)

    AsyncTask使用方法详情:http://www.cnblogs.com/zzw1994/p/4959949.html 下拉开源框架PullToRefresh使用方法和下载详情:http://ww ...

  3. openerp 常见问题 OpenERP在哪储存附件?(转载)

    OpenERP在哪储存附件? 原文地址:http://cn.openerp.cn/where_to_store_attachement_in_openerp_7/ 我们知道对OpenERP中的每个内部 ...

  4. Hive基本命令整理

    创建表: hive> CREATE TABLE pokes (foo INT, bar STRING);          Creates a table called pokes with t ...

  5. java中封装

    .什么是封装? 封装就是将属性私有化,提供公有的方法访问私有属性. 做法就是:修改属性的可见性来限制对属性的访问,并为每个属性创建一对取值(getter)方法和赋值(setter)方法,用于对这些属性 ...

  6. ASP.NET MVC NonActionAttribute使用说明

    默认情况下,MVC 框架将 controller 类的所有公共方法都视为操作方法. 如果您的 controller 类包含公共方法,并且您不希望它成为操作方法,则必须用 NonActionAttrib ...

  7. EF中使用Select new 方法中字段值替换的问题

    前提需要替换查询得到的List当中的某个字段的值,替换规则有一个mapping关系 尝试代码 有问题 无法获取任何数据 /// <summary> /// 获取Treegrid的List ...

  8. iOS常见问题(5)

    一.注意将之前storyboard中控制器删除之后,拖入一个新的控制器的时候,stroyboard中控制器的class也要重新填入自己想要展示的控制器,告诉stroyboard去加载哪个控制器. 二. ...

  9. C语言标准库函数strcpy与strcmp的简单实现

    //C语言标准库函数strcpy的一种简单实现. //返回值:目标串的地址. //对于出现异常的情况ANSI-C99标准并未定义,故由实现者决定返回值,通常为NULL. //参数:des为目标字符串, ...

  10. [转载+原创]Emgu CV on C# (一) —— Emgu CV on Visual C# 2010

    2014-08-16 最近要进行图像识别,准备利用几天的时间研究一下Emgu CV,花了一晚上功夫进行调试环境安装,期间遇到了不少问题,现梳理一下安装过程和调试过程中出现的问题. 中间有转载别人的部分 ...