Quicksum

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 102   Accepted Submission(s) : 33
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

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10000 int main()
{
long long n,L,i,sum;
char a[N];
while()
{
gets(a);
L=strlen(a);
if(L==&&a[]=='#')
break;
for(i=,sum=;i<L;i++)
{
if(a[i]==)
continue;
sum+=((a[i]-)*(i+)); }
printf("%lld\n",sum);
}
}

Quicksum的更多相关文章

  1. [字符哈希] POJ 3094 Quicksum

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

  2. Quicksum -SilverN

    quicksum Given a string of digits, find the minimum number of additions required for the string to e ...

  3. ACM——Quicksum

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

  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. POJ 3094 Quicksum 难度:0

    http://poj.org/problem?id=3094 #include<iostream> #include <string> using namespace std; ...

  9. poj 3094 Quicksum

    #include <stdio.h> #include <string.h> ]; int main() { ; int i,len; while(gets(word)) { ...

随机推荐

  1. linux入侵控制与痕迹清理

    后门 (1)开机自动反弹shell (2)linux后门 Rookit 目前常用的有:t0rn /mafix/enyelkm 等 mafix rootkit Mafix是一款常用的轻量应用级别Root ...

  2. c#弱事件(weak event)

    传统事件publisher和listener是直接相连的,这样会对垃圾回收带来一些问题,例如listener已经不引用任何对象但它仍然被publisher引用 垃圾回收器就不能回收listener所占 ...

  3. Java NIO Path接口和Files类配合操作文件

    Java NIO Path接口和Files类配合操作文件 @author ixenos Path接口 1.Path表示的是一个目录名序列,其后还可以跟着一个文件名,路径中第一个部件是根部件时就是绝对路 ...

  4. 《Intel汇编第5版》 汇编调用子过程

    一.Call和Ret指令 二.在子过程中需要自己保存可能会修改掉的寄存器值,这里可以使用USES伪指令来生成 三.一个数组求和的汇编例子 TITLE Call a Proc Demo INCLUDE ...

  5. vector,list,deque

    stl提供了三个最基本的容器:vector,list,deque. vector和built-in数组类似,它拥有一段连续的内存空间,并且起始地址不变,因此它能非常好的支持随即存取,即[]操作符,但由 ...

  6. Ubuntu 14.04 绑定固定 IP

    参考百度经验首先用root用户登录,然后输入你的root密码,如果不用root登录可以在命令之前添加sudo:然后编辑interfaces 文件,该文件位于/etc/network/下面, 执行如下命 ...

  7. Linux c 内存高速访问

    概述 要想高速利用内存就必须高效利用cpu cache,关于cpu cache这里就不多加讨论了,自己感兴趣可以google 而cpu访问内存的单位是cache line,因此高效利用cache li ...

  8. sqlserver判断字符串是否是数字

    sql2005有个函数ISNUMERIC(expression)函数:当expression为数字时,返回1,否则返回0.这只是一个菜鸟级的解决办法,大多数情况比较奏效. eg: ') --结果为1 ...

  9. iOS上传AppStore被拒原因及处理方案

    1.后台运行GPS 1.1 原文: Performance - 2.5.4 Your app declares support for location in the UIBackgroundMode ...

  10. electron的艰难安装之旅

    最近对前端开发很感兴趣,抽空研究了下前段的开发工具,发现比较流行的是sublime,atom,vscode等, 由于一直以来从事.net开发所以对vscode很感兴趣,在vscode的安装配置过程偶然 ...