Quicksum

时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte
总提交:615            测试通过:256

描述

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

输入

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.

输出

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

样例输入

ACM
MID CENTRAL
REGIONAL PROGRAMMING CONTEST
ACN
A C M
ABC
BBC
#

样例输出

46
650
4690
49
75
14
15

提示

题目来源

Mid-Central USA Region 2006

http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1027

 #include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string s;
ifstream in("./data.txt");
while(getline(in,s)){
cout<<s<<endl;
if(s=="#") return ;
int sum=;
for(size_t i=;i<s.length();i++)
{
if(s[i]!=' '){
sum+=(i+)*(s[i]-);
}
}
cout<<sum<<endl;
}
return ;
}

 

ACM——Quicksum的更多相关文章

  1. [字符哈希] POJ 3094 Quicksum

    Quicksum Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16488   Accepted: 11453 Descri ...

  2. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  3. Quicksum

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

  4. POJ3094 Quicksum

    POJ3094 Quicksum Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18517   Accepted: 1271 ...

  5. TJU Problem 2520 Quicksum

    注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520.   Quicksum Time L ...

  6. H - Quicksum(1.5.3)

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...

  7. HDU.2734 Quicksum

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

  8. SCNU ACM 2016新生赛决赛 解题报告

    新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...

  9. SCNU ACM 2016新生赛初赛 解题报告

    新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...

随机推荐

  1. linux C编程之makefile

    目的:       基本掌握了 make 的用法,能在Linux系统上编程.环境:       Linux系统,或者有一台Linux服务器,通过终端连接.一句话:有Linux编译环境.准备:      ...

  2. stm32 cortext-M3 类型对齐问题【worldsing笔记】

    经过细测,Cortex-M3的double类型必须4字节对齐访问,其他诸如float,int,short 可以非对齐访问.否则将会产生硬件异常!即访问double类型地址必须能被4整除,测试代码如下: ...

  3. hql注意事项一

    Space is not allowed after parameter prefix ':' [from EmPaperCatalogDef e where e.parentId =: pcdId]

  4. Javascript(jQuery)中绑定页面上所有按钮点击事件的几种方式

    方法一:使用document对象查找所有的按钮 [javascript] view plain copy 在CODE上查看代码片派生到我的代码片 //按照dom的方式添加事件处理 function B ...

  5. SQLite使用教程8 Insert 语句

    http://www.runoob.com/sqlite/sqlite-insert.html SQLite Insert 语句 SQLite 的 INSERT INTO 语句用于向数据库的某个表中添 ...

  6. 利用存储过程将表中的数据生成Insert语句

    1.创建存储过程 CREATE PROC [dbo].[sp_get_InsertSql] @dbName VARCHAR ( )= '' , -- 数据库名称 @tabList VARCHAR ( ...

  7. jquery回车提交表单

    jquery回车提交表单,比较方便的功能. 三个事件keydown,keypress,keyup,分别是按下,按着没上抬,上抬键盘 ,所以用keyup. $(document).keyup(funct ...

  8. android学习日记28--Android中常用设计模式总结

    一.综述 设计模式,根据前人经验总结出常见软件工程问题的解决思想套路.GoF一共归纳了23种设计模式,当然还有人扩充,不止这些.设计模式主要利用面向对象语言的特性,而android 的设计主要用JAV ...

  9. MySQL 性能监控 4 大指标

    [编者按]本文作者为 John Matson,主要介绍 mysql 性能监控应该关注的 4 大指标. 文章系国内 ITOM 管理平台 OneAPM 编译呈现.    MySQL 是什么? MySQL  ...

  10. 解决安装包在win7,win8系统下安装后运行没有管理员权限

    今天打包一个程序在客户机上安装运行:一直报没有管理员权限:客户机是win8系统:直接右键管理员身份运行则都可以:为了避免不让用户每次都这么麻烦:只有问哈群友和百度,终于找到解决方法: 第一步:项目属性 ...