Quicksum

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3401 Accepted Submission(s): 2095
 
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 = 46MID 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
 
 
Source
Mid-Central USA 2006
 
Recommend
teddy
 
 #include <string.h>
#include <stdio.h> int main()
{
char str[];
int len,i,a[],sum;
for(i = ;i<;i++)
{
a[i] = i+;
}
while(gets(str))
{
if(strcmp(str,"#") == )
break;
len = strlen(str);
sum = ;
for(i = ;i<len;i++)
{
if(str[i]>='A' && str[i]<='Z')
sum+=(i+)*a[str[i]-'A'];
}
printf("%d\n",sum);
} return ;
}

HDU------checksum的更多相关文章

  1. HDU 5536 Chip Factory 字典树

    Chip Factory Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  2. hdu 5536 Chip Factory (01 Trie)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=5536 题面; Chip Factory Time Limit: 18000/9000 MS (Java/O ...

  3. HDU.2734 Quicksum

    Quicksum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  4. HDU 5536 Chip Factory 【01字典树删除】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5536 Chip Factory Time Limit: 18000/9000 MS (Java/Ot ...

  5. PE Checksum Algorithm的较简实现

    这篇BLOG是我很早以前写的,因为现在搬移到CNBLOGS了,经过整理后重新发出来. 工作之前的几年一直都在搞计算机安全/病毒相关的东西(纯学习,不作恶),其中PE文件格式是必须知识.有些PE文件,比 ...

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

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

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

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

  8. hdu 4859 海岸线 Bestcoder Round 1

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

  9. HDU 4569 Special equations(取模)

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

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

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

随机推荐

  1. Mvc的多层架构

    分享一个Mvc的多层架构,欢迎大家拍砖斧正   多层架构是什么? 多层架构是开发人员在开发过程当中面对复杂且易变的需求采取的一种以隔离控制为主的应对策略,关于多层架构的标准,我认为有一句话是比较有代表 ...

  2. C#事件与委托的区别

    C#事件与委托的区别 1. 委托 事件是利用委托来定义的,因此先解释委托.委托是一个类,它与其他类如int,string等没有本质区别,int代表的是所有的整形,而string代表的是字符串,委托则代 ...

  3. warfare(最大生成树裸题)

                                                                                                  战争 [问题 ...

  4. CentOS6.8安装JDK1.7

    一.查看当前系统是否自带JDK rpm -qa | grep java tzdata-java-2016c-1.el6.noarch java-1.7.0-openjdk-1.7.0.99-2.6.5 ...

  5. MongoDB学习2

    MongoDB学习(翻译2) C#驱动之LINQ教程 介绍 本教程涵盖了1.8发布版本对linq查询的支持. 开始本教程之前,你应该至少阅读下C#驱动教程关于C#驱动的介绍 快速开始 首先,添加下面命 ...

  6. 【Yom框架】漫谈个人框架的设计之三:业务接口+UI层的设计(基于Castle实现的Repository)

    Repository层设计的文章见:[http://www.cnblogs.com/yomho/p/3297042.html]   一.概要设计 上面Reposity 应该为 Repository 特 ...

  7. Aliexpress API 测试工具

    Aliexpress API 测试工具 上回简单说了 Aliexpress API 的认证流程, 这回在奉送一个小工具, API 测试工具. 点我下载 做这一行,和做程序员的生活完全不搭调, 格格不入 ...

  8. 单一职责原则SRP

    定义: There should nerver be more then one reason for a class to change. 优点: 1.类的复杂性降低,实现什么职责都有清晰明确的定义 ...

  9. iOS 开发之Target-action模式

    Target-action:目标-动作模式,它贯穿于iOS开发始终.但是对于初学者来说,还是被这种模式搞得一头雾水. 其实Target-action模式很简单,就是当某个事件发生时,调用那个对象中的那 ...

  10. SystemTray文字颜色问题

    今天想给SystemTray的ForegroundColor设置为白色,但是模拟器正确,真机仍为黑色.经过一番折腾,发现是微软做了限制,背景是什么颜色,ForegroundColor就不能为什么颜色. ...