Poj 2403 Hay Points(Map)
一、题目大意
实现一个工资计算系统。工资的计算规则是:首先,给定一些关键字和对应的价值,这个相对于字典。然后给出的是求职者的描述,如果这个描述中包含关键字则加上对应的价值,总得价值就是这个求职者的工资。
二、题解
实现很简单,把关键字和价值用一个Map先存起来,然后依次读取描述,关键字相同则加上价值量。
三、java代码
import java.util.HashMap;
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int m,n,i,num;
String s;
m=sc.nextInt();
n=sc.nextInt();
HashMap<String,Integer> map=new HashMap<String,Integer>();
for(i=0;i<m;i++){
map.put(sc.next(),sc.nextInt());
}
while(n--!=0){
num=0;
while(!((s=sc.next()).equals("."))){
if(map.containsKey(s))
num+=map.get(s);
}
System.out.println(num);
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Poj 2403 Hay Points(Map)的更多相关文章
- POJ 2403 Hay Points
Hay Points Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5735 Accepted: 3695 Descri ...
- Hay Points
Hay Points TimeLimit: 1 Second MemoryLimit: 32 Megabyte Totalsubmit: 1022 Accepted: 602 Descript ...
- poj 2403
http://poj.org/problem?id=2403 题意:就是给你m个单词,以及n段对话.每一个单词都有所对应的价值.求对话中的价值总和 题解:很简单,就是用单词和价值对应起来,然后再寻找就 ...
- poj 2418 Hardwood Species (map)
题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器. c++ AC代码,G++为超时,上代码: #include<cstdio ...
- poj 2503 Babelfish (查找 map)
题目:http://poj.org/problem?id=2503 不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...
- POJ - 2464 Brownie Points II 【树状数组 + 离散化】【好题】
题目链接 http://poj.org/problem?id=2464 题意 在一个二维坐标系上 给出一些点 Stan 先画一条过一点的水平线 Odd 再画一条 过Stan那条水平线上的任一点的垂直线 ...
- POJ 3805 Separate Points (判断凸包相交)
题目链接:POJ 3805 Problem Description Numbers of black and white points are placed on a plane. Let's ima ...
- hdu 1156 && poj 2464 Brownie Points II (BIT)
2464 -- Brownie Points II Problem - 1156 hdu分类线段树的题.题意是,给出一堆点的位置,stan和ollie玩游戏,stan通过其中一个点画垂线,ollie通 ...
- POJ 1840 Eqs 二分+map/hash
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...
随机推荐
- POJ 2965 The Pilots Brothers' refrigerator【枚举+dfs】
题目:http://poj.org/problem?id=2965 来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26732#pro ...
- iOS-事件传递和响应机制
转自:http://www.jianshu.com/p/2e074db792ba 前言: 按照时间顺序,事件的生命周期是这样的: 事件的产生和传递(事件如何从父控件传递到子控件并寻找到最合适的view ...
- android启动页延时跳转
package com.goodness.goodness; import android.content.Context; import android.content.Intent; import ...
- ubuntu查看Mysql是否已启动
sudo netstat -tap | grep mysql 命令行输出: tcp6 0 0 [::]:mysql [::]:* ...
- table control里面各种属性和事件
[转自]http://blog.csdn.net/hackai886/article/details/7935366 SAP中,Table Control是在Screen中用的最广泛的控件之一了,可以 ...
- (转)Javascript模块化编程(一):模块的写法
随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分工协作.进度管理.单元测试等等......开发者 ...
- springboot5
1.改造购物车系统 1.1.创建购物车的Spring Boot工程 1.1.导入依赖 <project xmlns="http://maven.apache.org/POM/4.0.0 ...
- 【leetcode刷题笔记】Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...
- 【leetcode刷题笔记】Sort List
Sort a linked list in O(n log n) time using constant space complexity. 题解:实现一个链表的归并排序即可.主要分为三部分: 1.找 ...
- 321list,元组,range**数字是不可迭代的!
一.list(列表) 列表是python中的基础数据类型之一,他是以[]括起来,每个元素以逗号隔开,而且他里面可以存放各种数据类型.列表相比于字符串,不仅可以储存不同的数据类型,而且可以储存大量数据, ...