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. Unity3DGUI:Window

    #pragma strictvar winRect:Rect=Rect(30,100,150,200);var windowShow:boolean=true;function OnGUI () { ...

  2. awk学习笔记二:调用shell、文件执行(转)

    awk 'BEGIN {print "Hello"}' 不操作文件直接处理数据流 要调用shell则可以用管道命令 如,打印日期awk 'BEGIN {"date&quo ...

  3. 支付宝AR实景红包上线不久即遭破解,官方已提高技术门槛

    临近春节,阿里巴巴和腾讯的红包大战可谓下足功夫,上周支付宝推出了AR实景红包,该玩法基于"LBS+AR+红包"的方式,类似与今年火爆全球的AR手游Pekomon Go ,只不过这次 ...

  4. Ecstore安装篇-1.运行系统环境要求

    运行系统环境要求 运行系统环境要求 author :James,jimingsong@vip.qq.com since :2015-03-01 支持的操作系统 支持的WEB服务器 支持的浏览器 支持的 ...

  5. LeetCode 328. Odd Even Linked List C#

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  6. php专业面试总结

    PHP专业面试题汇总 一.PHP基础: 2 二.数据库部分 5 三.面向对象部分 9 四.ThinkPHP部分 12 五.smarty模板引擎 16 六.二次开发系统(DEDE.ecshop): 18 ...

  7. JavaScript DOM编程艺术-学习笔记(第五章、第六章)

    第五章: 1.题外话:首先大声疾呼,"js无罪",有罪的是滥用js的那些人.js的father 布兰登-艾克,当初为了应付工作,10天就赶出了这个js,事后还说人家js是c语言和s ...

  8. DNS服务架设 redhat linux

    安装dns服务和管理工具 yum install bind   bind-chroot bind-utils -y 服务名为named 在没有启动服务之前服务的主配置文件在/etc/named.con ...

  9. JAVA中数组总结(课堂总结)

    数组的特点: Arrays(数组)一种简单的数据结构元素具有相同的数据类型一旦创建之后,尺寸保持不变元素在内存中连续分布例子一:按引用与按值传递的示例源代码: // PassArray.java // ...

  10. 在Linux中让文本显示带颜色的字。

    在linux中让echo命令显示带颜色的字需要使用参数-e 格式:echo -e "\33[字体背景颜色:文字颜色m字符转\033[0m" 注: 1.字体背景颜色和文字颜色之间是英 ...