FZU 1008 Hay Points
2009-07-19 16:17
246 查看
Hay Points
题目大意:
在某机关的每个员工都有一个关于其所负责工作的描述。这个工作描述表达了该员工的重要性,所以也常被用来决定一个员工的薪资。
人事部门希望能有一个叫做Hay Point的系统,根据每个员工的工作描述,来帮他们自动完成计算薪资的工作。如果某个员工的工作描述中有指出控制大笔经费或管理许多人,那他的Hay Point就会比较高,也就是薪水较高。你的任务就是完成这个Hay Point系统。我们会给你一个 Hay Point的字典以及许多人的工作描述。对每个人的工作描述,请你算出他得到多少Hay Point。
Input
输入的第一列有2个正整数,m,n(m<=1000,n<=100)。m代表在Hay Point字典中有多少字。n代表有多少个工作描述。接下来的m列每列有一个英文单字(最多16个小写字母)及一个实数(就是Hay Point,范围介于0到1000000之间)。在字典之后有n个工作描述,每个描述可能有一到多列。为了方便起见,所有的描述都被转换为小写英文字母,并且除了英文字母,数字,空格符之外没有其它字符。每一工作描述以只含有一句点的一列作为结束。请参考Sample Input。
Output
根据输入的工作描述中的每个字,如果这个字出现在字典中,则得到该字的Hay Point。如果这个字未出现在字典中,则这个字得到0个Hay Point。对每个工作描述,输出这位员工共得到多少Hay Point。
解题:
重要的是理解题意,对比工作描述,若是与Hay Point 上有相同的工作职能的话,即单词一样的话,就工资叠加。
Time Limit:1s | Memory limit:32M |
Accepted Submit:399 | Total Submit:673 |
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 Original: waterloo 020601 |
在某机关的每个员工都有一个关于其所负责工作的描述。这个工作描述表达了该员工的重要性,所以也常被用来决定一个员工的薪资。
人事部门希望能有一个叫做Hay Point的系统,根据每个员工的工作描述,来帮他们自动完成计算薪资的工作。如果某个员工的工作描述中有指出控制大笔经费或管理许多人,那他的Hay Point就会比较高,也就是薪水较高。你的任务就是完成这个Hay Point系统。我们会给你一个 Hay Point的字典以及许多人的工作描述。对每个人的工作描述,请你算出他得到多少Hay Point。
Input
输入的第一列有2个正整数,m,n(m<=1000,n<=100)。m代表在Hay Point字典中有多少字。n代表有多少个工作描述。接下来的m列每列有一个英文单字(最多16个小写字母)及一个实数(就是Hay Point,范围介于0到1000000之间)。在字典之后有n个工作描述,每个描述可能有一到多列。为了方便起见,所有的描述都被转换为小写英文字母,并且除了英文字母,数字,空格符之外没有其它字符。每一工作描述以只含有一句点的一列作为结束。请参考Sample Input。
Output
根据输入的工作描述中的每个字,如果这个字出现在字典中,则得到该字的Hay Point。如果这个字未出现在字典中,则这个字得到0个Hay Point。对每个工作描述,输出这位员工共得到多少Hay Point。
解题:
重要的是理解题意,对比工作描述,若是与Hay Point 上有相同的工作职能的话,即单词一样的话,就工资叠加。
#include <iostream> #include <string> using namespace std; int main() { int a,b; char m[1001][17]; char words[20]; int n[1001]; int money[101]; memset(money,0,101); cin>>a>>b; for(int i=0;i<a;i++) cin>>m[i]>>n[i]; for(int j=0;j<b;j++) { while(cin>>words) { if(words[0]=='.') { break; } for(int k=0;k<a;k++) { if(strcmp(words,m[k])==0) money[j]=money[j]+n[k]; } } } for(int p=0;p<b;p++) { cout<<money[p]<<endl; } return 0; }
相关文章推荐
- NYOJ27水池数目,类似于FZU1008最大黑区域,简单搜索题~~~
- 【FOJ 1008】Hay Points
- fzu 2213 通过圆心坐标和半径判断两圆的关系
- 1008 选数
- 1008. Elevator (20)
- 搜索练习2/fzu.edu.cn/problem2150 Fire Game (bfs)
- 每日三题-Day6-A(FZU 2214 Knapsack problem 01背包)
- hdu 1008 Elevator
- COJ-1008-Horcrux
- FZU - 2150 Fire Game
- FZU2214 Knapsack problem--01背包
- 1008. Elevator (20)
- PAT甲级1008
- FZU 2140 Forever 0.5
- fzu Fire Game bfs
- 1008. 数组元素循环右移问题 (20)
- FZU 2235 国王的出游【离散化+Bfs】
- FZU - 2191 完美的数字
- Fzu 2203 单纵大法好【二分+贪心】
- Fzu 2157 ProgramCaicai's Trees【树型dp】