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. 跟着Android官网学习Activity

    1.Activity介绍 An Activity is an application component that provides a screen with which users can int ...

  2. Android实例-使用自定义字体文件(XE8+小米2)

    结果: 1.需要修改DELPHI自身的FMX.FontGlyphs.Android.pas,复制到程序的根目录下(红色部分为修改过的). 2.字体文件从 C:\Windows\Fonts 直接拷贝到A ...

  3. delphi 删除目录和创建目录,临时文件夹

    获取用户当前的Windows临时文件夹function GetWinTempPath: string;varTempDir: array[0..255] of char;beginGetTempPat ...

  4. hdoj 2045 不容易系列之(3)—— LELE的RPG难题

    不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...

  5. hbase运维

    NoSQL现在风生水起,hbase的使用也越来越广,但目前几乎所有的NoSQL产品在运维上都没法和DB相提并论,在这篇blog中来总结下我们在运维hbase时的一些问题以及解决的方法,也希望得到更多h ...

  6. Android动画Animation之Tween用代码实现动画

    透明度动画.旋转动画.尺寸伸缩动画.移动动画 package com.javen.tween; import android.annotation.SuppressLint; import andro ...

  7. C++11 std::bind std::function 高级使用方法

    从最基础的了解,std::bind和std::function /* * File: main.cpp * Author: Vicky.H * Email: eclipser@163.com */ # ...

  8. ASC(1)G(上升时间最长的序列)

    G - Beautiful People Time Limit: 10000/5000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Other ...

  9. iOS开发——开发技巧&Git常用命令

    Git常用命令 初始化git init        加—bare实现远程仓库 配置git config user.name iCocos 配置全局git config —global user.na ...

  10. Tomcat配置域名访问

    在server.xml文件中的<Host>标签里面添加 <Alias>你的域名(比如:www.baidu.com)</Alias> <Context path ...