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. zabbix 布署实践【4 服务器自动探索发现,并且自动关联模版】

    使用管理员登录zabbix后,在配置---自动发现--创建发现规则 如下:我们的需求是监听办公网内openstack的所有虚拟机,在其VM创建后,自动加到zabbix监控中来,并自动关联监控模版 可以 ...

  2. ASP.NET网站怎么发布 Web项目程序怎么发布部署(暂时收藏)

    Web程序如何发布部署呢.网站项目做好了,需要发布出来,提交给客户,装上服务器.那怎么在ASP.NET开发环境中将网站程序发布出来呢 ^_^   工具/原料 Visual Studio 2010  ( ...

  3. jsp:useBean的使用

    ->Bean的基本要素: 1.必须要有一个不带参数的构造器,在jsp元素创建Bean时会调用空构造器 2.Bean类应该没有任何公共实例变量,也就是说,不允许直接访问实例变量,通过setter/ ...

  4. appnium框架以及源码研究

    android4.0后,google提供了uiautomator来进行自动化方案,appium在高版本android上就是基于这个,4.0下是基于selendroid. appium相当于一个中转站, ...

  5. git和SVN的区别

    1)Git是分布式的,SVN不是: 这 是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别.好处是跟其他同事不会有太多的冲突,自己写的代码放在自己电脑上,一段时间后再提交.合并, ...

  6. ArcGIS 10.5 named user介绍

    1           Named user概述 1.1    Named user简介 Named user是ArcGIS产品自10.3版本正式推出的一种以用户为中心的授权机制,也称"授权 ...

  7. centos7 安装openvswitch

    安装 1.安装依赖包:yum -y install openssl-devel wget kernel-devel 2.安装开发工具:yum groupinstall "Developmen ...

  8. opencv3.1自带demo的介绍和运行操作。转载

    opencv3.1自带demo的介绍和运行操作. 下列实验基本都试过,有些需要根据自己的电脑修改一些路径或者调试参数. 值得注意的是,控制台程序输入有时候要在图像所在的窗口输入相应的指令.我的电脑上安 ...

  9. this的相关知识

    一如既往,直接上代码: function fn(name,age){ var obj=new Object(); obj.name=name; obj.age=age; obj.talk=functi ...

  10. 初学者必知的HTML规范

    一.整体结构 用div代替table布局 结构.表现.行为三者分离,避免内联 良好的树形结构四个空格代替一个tab 能并列就不嵌套<div></div><div>& ...