Quicksum

Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 3516 Accepted Submission(s): 2579

Problem Description

A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necessary to detect undesirable changes in data.

For this problem, you will implement a checksum algorithm called Quicksum. A Quicksum packet allows only uppercase letters and spaces. It always begins and ends with an uppercase letter. Otherwise, spaces and letters can occur in any combination, including consecutive spaces.

A Quicksum is the sum of the products of each character’s position in the packet times the character’s value. A space has a value of zero, while letters have a value equal to their position in the alphabet. So, A=1, B=2, etc., through Z=26. Here are example Quicksum calculations for the packets “ACM” and “MID CENTRAL”:

ACM: 1*1 + 2*3 + 3*13 = 46

MID CENTRAL: 1*13 + 2*9 + 3*4 + 4*0 + 5*3 + 6*5 + 7*14 + 8*20 + 9*18 + 10*1 + 11*12 = 650

Input

The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters.

Output

For each packet, output its Quicksum on a separate line in the output.

Sample Input

ACM

MID CENTRAL

REGIONAL PROGRAMMING CONTEST

ACN

A C M

ABC

BBC

Sample Output

46

650

4690

49

75

14

15

题意分析:

水题。每个英文字母在字符串的的位置乘英文字母在字母表中的位置求和即可。注意空格也算一个字符。

代码:

/*
Title:HDU.2734
Date:2016-9-30
Author:pengwill
Blog: http://blog.csdn.net/pengwill97
*/
#include<stdio.h>
#include<string.h>
int main()
{
int sum= 0;
char ch[300];
while(gets(ch) && ch[0] != '#'){
int len = strlen(ch);
int i;
sum = 0;
for(i = 0;i<len;i++){
if(ch[i] == ' '){
continue;
}else{
sum+=(i+1) * (ch[i] - 64);
}
}
printf("%d\n",sum);
}
return 0;
}

HDU.2734 Quicksum的更多相关文章

  1. HDU ACM-Steps

    HDU ACM-Steps RECORD Chapter 1 Section 1 暖手题 1.1.1 A+B for Input-Output Practice (I) #include <st ...

  2. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  3. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. hdu1422重温世界杯(动态规划,最长子序列)

    重温世界杯 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  2. Python字符串格式化符号及转义字符含义(非常全!!!)

    字符串格式化符号含义 符号 说明 %c 格式化字符及其 ASCII 码 %s 格式化字符串 %d 格式化整数 %o 格式化无符号八进制数 %x 格式化无符号十六进制数 %X 格式化无符号十六进制数(大 ...

  3. 传入中文参数-->服务器_转码的方法

    如果要传入 中文参数到 服务器 使用lr_convert_string_encoding()                            LR_ENC_SYSTEM_LOCALE ,  转为 ...

  4. 《Git学习指南》学习笔记(一)

    第二章 入门 git的安装 在Linux下,git的安装很简单.以我的系统Deepin/Ubuntu为例,只需在终端敲入sudo apt-get install git即可.其他Linux发行版可尝试 ...

  5. Vue-cli 工具 / 通过 Vue-cli 工具重构 todoList

    本博文归纳在 Vue 学习过程中, Vue-cli 工具的使用说明.除此之外还通过 Vue-cli 工具将之前 Vuejs 基本语法当中实现的 todoList 进行重构. 安装 npm instal ...

  6. How Does Batch Normalization Help Optimization?

    1. 摘要 BN 是一个广泛应用的用于快速稳定地训练深度神经网络的技术,但是我们对其有效性的真正原因仍然所知甚少. 输入分布的稳定性和 BN 的成功之间关系很小,BN 对训练过程更根本的影响是:它让优 ...

  7. chameleon-Mini(迷你变色龙)

    Chameleon Mini(迷你变色龙)是一个比一般信用卡稍大的小型开发板,是开源产品. 如图 Chameleon Mini可以完全复制许多商业非接触式智能卡包括UID卡,在内的全部内容,因此可以用 ...

  8. 11.22Daily Scrum

    人员 任务分配完成情况 明天任务分配 王皓南 实现网页上视频浏览的功能.研究相关的代码和功能.979 数据库测试 申开亮 实现网页上视频浏览的功能.研究相关的代码和功能.978 实现视频浏览的功能 王 ...

  9. JavaScript初探系列之日期对象

    时间对象是一个我们经常要用到的对象,无论是做时间输出.时间判断等操作时都与这个对象离不开.它是一个内置对象——而不是其它对象的属性,允许用户执行各种使用日期和时间的过程. 一   Date 日期对象 ...

  10. laravel开发环境部署遇到的问题和个人感受

    >感受 用chrome浏览器 英语很重要 跟上更新的步伐 要不断学习 问问题要把问题描述清楚,先尝试解决,解决不了再问大佬 情绪要稳定,不能因为一个问题困扰两天就想放弃了 发现了 stack o ...