UVa 11340 Newspaper (water ver.)
来源:互联网 发布:网络梗集合 编辑:程序博客网 时间:2024/05/20 05:03
11340 - Newspaper
Time limit: 1.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2315
News agency pays money for articles according to some rules. Each character has its own value (some characters may have value equals to zero). Author gets his payment as a sum of all character's values in the article. You have to determine the amount of money that news agency must pay to an author.
INPUT:
The first line contains integer N (0 < N <= 5), it is a number of tests. Each test describes an integer K (0 < K <= 100), the number of paid characters. On next K lines there are table of paid characters and its values (character values are written in cents). If character can not be found in the table, then its value is equal to zero. Next, there is integer M (0 < M <= 150000). Next M lines contain an article itself. Each line can be up to 10000 characters length. Be aware of a large input size, the whole input file is about 7MB.OUTPUT:
For each test print how much money publisher must pay for an article in format "x.yy$
". Where "x
" is a number of dollars without leading zeros, and "yy
" number of cents with one leading zero if necessary. Examples: "3.32$
", "13.07$
", "71.30$
", "0.09$
".SAMPLE INPUT:
17a 3W 10A 100, 10k 7. 3I 137ACM International Collegiate Programming Contest (abbreviatedas ACM-ICPC or just ICPC) is an annual multi-tiered competitionamong the universities of the world. The ICPC challenges studentsto set ever higher standards of excellence for themselvesthrough competition that rewards team work, problem analysis,and rapid software development.From Wikipedia.
SAMPLE OUTPUT:
3.74$
直接开个130大小的数组把char对应的值存起来~
/*0.036s*/#include<cstdio>#include<cstring>int ch[130];char str[10005];int main(){int n, k, val, m, len, i;long long sum;char c;scanf("%d", &n);while (n--){memset(ch, 0, sizeof(ch));scanf("%d\n", &k);while (k--){c = getchar();scanf("%d\n", &val);ch[c] = val;}scanf("%d\n", &m);sum = 0;while (m--){gets(str);len = strlen(str);for (i = 0; i < len; ++i)sum += ch[str[i]];}printf("%.2f$\n", (double)sum / 100);}return 0;}
- UVa 11340 Newspaper (water ver.)
- UVa 11340 - Newspaper
- Uva Oj 11340 - Newspaper
- UVa 11340 Newspaper
- UVa 10082 WERTYU (water ver.)
- UVa 10696 f91 (water ver.)
- UVa 79 ClockHands (water ver.)
- UVa 514 Rails (water ver.)
- UVa 11150 Cola (water ver.)
- UVa 10300 Ecological Premium (water ver.)
- UVa 414 Machined Surfaces (water ver.)
- UVa 490 Rotating Sentences (water ver.)
- UVa 445 Marvelous Mazes (water ver.)
- UVa 488 Triangle Wave (water ver.)
- UVa 10783 Odd Sum (water ver.)
- UVa 457 Linear Cellular Automata (water ver.)
- UVa 621 Secret Research (water ver.)
- UVa 11044 Searching for Nessy (water ver.)
- 循环链表,双链表,顺序表和链表的比较
- javaBean产生的背景
- javabean的基本概念
- WIFI四种省电模式的含义
- javabean的属性、事件和方法
- UVa 11340 Newspaper (water ver.)
- IO_02
- WIFI-SDIO 五问五答
- 论c++计算机二级考试
- javabean的特征
- javabean特征简介
- heapSort
- 使用UltraISO制作U盘启动盘
- 【LeetCode】Maximum Subarray (最大连续子序列和)