Problem 1008 Hay Points

Problem Description

Each employee of a bureaucracy has a job description - a few paragraphs that describe the responsibilities of the job. The employee‘s job description, combined with other factors, such as seniority, is used to determine his or her salary.

The Hay Point system frees the Human Resources department from having to make an intelligent judgement as to the value of the employee; the job description is merely scanned for words and phrases that indicate responsibility. In particular, job descriptions that indicate control over a large budget or management over a large number of people yield high Hay Point scores.

You are to implement a simplified Hay Point system. You will be given a Hay Point dictionary and a number of job descriptions. For each job description you are to compute the salary associated with the job, according to the system.

The first line of input contains 2 positive integers: m <= 1000, the number of words in the Hay Point dictionary, and n <= 100, the number of job descriptions. m lines follow; each contains a word (a string of up to 16 lower-case letters) and a dollar value (a real number between 0 and 1,000,000). Following the dictionary are the n job descriptions. Each job description consists of one or more lines of text; for your convenience the text has been converted to lower case and has no characters other than letters, numbers, and spaces. Each job description is terminated by a line containing a period.

For each job description, output the corresponding salary computed as the sum of the Hay Point values for all words that appear in the description. Words that do not appear in the dictionary have a value of 0.

Sample Input

7 2 administer 100000 spending 200000 manage 50000 responsibility 25000 expertise 100 skill 50 money 75000 the incumbent will administer the spending of kindergarden milk money and exercise responsibility for making change he or she will share responsibility for the task of managing the money with the assistant whose skill and expertise shall ensure the successful spending exercise . this individual must have the skill to perform a heart transplant and expertise in rocket science .

Sample Output

700150

150

题目比较简单,但对于我这种英语渣渣来说太痛苦了,连看带猜在加上样例终于把题意搞懂了,就是每个单词对应一个数字,在一大堆单词里找到有多少个和那些单词相等,加上他们相应的数字就行,so easy!

1 #include <iostream>
 2 using namespace std;
 3 
 4 struct w
 5 {
 6        string s;
 7        int p;
 8 }k[1100];
 9 int main()
10 {
11     int n,m,sum;
12     string str;
13     while (cin>>n>>m)
14     {
15           for (int i=1;i<=n;i++)
16           cin>>k[i].s>>k[i].p;
17           sum=0;
18           for (int i=1;i<=m;i++)
19           {
20               while (cin>>str&&str!=".")
21               {
22                     for (int j=1;j<=n;j++)
23                     if (k[j].s==str)
24                     sum+=k[j].p;
25               }
26               cout <<sum<<endl;
27               sum=0;
28           }
29     }
30     return 0;
31 }

时间: 2024-11-05 22:54:35

Problem 1008 Hay Points的相关文章

UVa 10295 - Hay Points

题目:有非常多工人.相应一个能力描写叙述表,每种能力有一个权值,求每一个工人的能力值. 分析:字符串.hash表,字典树.利用散列表或者字典树存储相应的单词和权值.查询就可以. 说明:注意初始化,计算完将数据清除. #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> using namespace std; //hash_define typedef stru

AtCoder Grand Contest 025 Problem D - Choosing Points

题目大意:输入$n,d1,d2$,你要找到$n^2$个整点 x, y 满足$0 \leqslant x, y<2n$.并且找到的任意两个点距离,既不是$\sqrt{d1}$,也不是 $\sqrt{d2}$. 题解:如果$d mod 2=1$,如果$a^2+b^2=d$,a和b一定一奇一偶,按国际象棋黑白染色即可.如果$d mod 4=2$,如果$a^2+b^2=d$,a和b一定都是奇数,一行黑色,一行白色即可.如果$d mod 4=0$,把$2×2$的区域看成一个大格子,对$d/4$进行如上考虑

HDU contest808 ACM多校第7场 Problem - 1008: Traffic Network in Numazu

首先嘚瑟一下这场比赛的排名:59 (第一次看到这么多 √ emmmm) 好了进入正文QAQ ...这道题啊,思路很清晰啊. 首先你看到树上路径边权和,然后还带修改,不是显然可以想到 树剖+线段树 维护重链么? 然后你再看啊,这是一个连通图,然后有 n 个点 n 条边,于是很显然会有一个环(然后就构成了一个 仙人掌 ...不过我并不了解仙人掌) 然后你再看!这里只会有一个环,我们假设没有这个环,那么这就是一道 树剖 模板题,那么我们可不可以特殊地,让这个环当根,除这个环以外的其他节点来简单 树剖

BZOJ 1008: [HNOI2008]越狱 组合数学

原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1008 题解: 就很傻逼的组合数学啊... $$ans=M^N-M*(M-1)^{(N-1)}$$ 代码: /************************************************************** Problem: 1008 User: HarryGuo2012 Language: C++ Result: Accepted Time:0 ms Memo

BZOJ 1008 题解

1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7845  Solved: 3359[Submit][Status][Discuss] Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10

bzoj 1008 组合计数

正难则反 前面定后面就定->枚举开头 1 /************************************************************** 2 Problem: 1008 3 User: idy002 4 Language: C++ 5 Result: Accepted 6 Time:0 ms 7 Memory:804 kb 8 ****************************************************************/ 9 1

ZCMU Problem A: Good Joke!

Problem A: Good Joke! Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 25  Solved: 16[Submit][Status][Web Board] Description Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem: Given N 

【BZOJ】【1008】【HNOI】越狱

快速幂 大水题= = 正着找越狱情况不好找,那就反过来找不越狱的情况呗…… 总方案是$m^n$种,不越狱的有$m*(m-1)^(n-1)$种= = 负数搞搞就好了…… 莫名奇妙地T了好几发…… 1 /************************************************************** 2 Problem: 1008 3 User: Tunix 4 Language: C++ 5 Result: Accepted 6 Time:0 ms 7 Memory:8

九度 题目1008:最短路径问题

最短路径问题,首先想到了贪心算法实现的dijkstra算法:这道题我用了链表的存储方式,其实用邻接矩阵也可以,主要为了练手,并且链表比矩阵要节约空间: 题目描述: 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的. 输入: 输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p.最后一行是两个数 s,t;起点s,终点t.n和m为0时输入结