POJ 3094 Quicksum
2012-10-24 11:53
302 查看
一、题目信息
QuicksumTime Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 11249 | Accepted: 7741 |
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 = 650InputThe 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.OutputFor 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
二、参考代码
很水很水的题目,参考代码如下,如有更简洁算法,请讨论之。
#include <stdio.h>int main(){char c;int sum = 0,pos = 1;while(1){c = getchar();if(c == '#')break;else if (c == '\n'){printf("%d\n",sum);sum = 0;pos = 1;continue;}else{sum += (c == ' ') ? 0 : pos*(c - 'A' + 1);pos++;}}return 0;}
相关文章推荐
- POJ 3094 Quicksum 水
- POJ 3094 Quicksum
- Poj 3094 Quicksum
- Poj 3094 Quicksum
- poj 3094 Quicksum
- Quicksum--POJ 3094
- POJ3094 UVALive3594 HDU2734 ZOJ2812 Quicksum【进制】
- POJ 3094 Quicksum
- poj 3094 Quicksum
- POJ 3094 Quicksum
- POJ-3094-Quicksum-2013-12-02 21:10:02
- POJ 3094 Quicksum
- POJ 3094 && HDU 2734 Quicksum(水~)
- poj-3094-quicksum
- poj 3094 Quicksum
- POJ 3094 Quicksum
- poj 3094 Quicksum
- POJ 3094 Quicksum
- POJ 刷题系列:3094. Quicksum
- POJ 3094 Quicksum G++