Poj 2503 Babelfish(Map操作)
一、Description
Input
word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
二、题解
只要用Map把字典存起来,注意键值对的顺序,这里应该后面的字符串为键,前面的为值。然后再依次查找就可以了。
三、java代码
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap; public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bfd=new BufferedReader(new InputStreamReader(System.in));
HashMap<String,String> hm=new HashMap<String,String>();
String s;
String [] seq=new String[2];
while(!(s=bfd.readLine()).equals("")){
seq=s.split(" ");
hm.put(seq[1], seq[0]);
}
while(!(s=bfd.readLine()).equals("")){
if(hm.containsKey(s))
System.out.println(hm.get(s));
else
System.out.println("eh");
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Poj 2503 Babelfish(Map操作)的更多相关文章
- poj 2503 Babelfish(Map、Hash、字典树)
题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码( ...
- poj 2503 Babelfish (查找 map)
题目:http://poj.org/problem?id=2503 不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...
- POJ 2503 Babelfish(map,字典树,快排+二分,hash)
题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP ...
- 题解报告:poj 2503 Babelfish(map)
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...
- poj 2503 Babelfish(字典树或map或哈希或排序二分)
输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了M ...
- poj 2503 Babelfish(字典树或着STL)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 35828 Accepted: 15320 Descr ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- POJ 2503 Babelfish
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28766 Accepted: 12407 Descripti ...
- POJ 2503 Babelfish (STL)
题目链接 Description You have just moved from Waterloo to a big city. The people here speak an incompreh ...
随机推荐
- 九度OJ 1188:约瑟夫环 (约瑟夫环)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1891 解决:817 题目描述: N个人围成一圈顺序编号,从1号开始按1.2.3......顺序报数,报p者退出圈外,其余的人再从1.2.3 ...
- Java基础 - 变量转换
在java中变量转发分为两种,隐式转换和强制转换 隐式转换: byte a = 10; int b = 20; byte c = a + b; // 该方法会报错,转换过程中字节数只能从小变大,不能从 ...
- SSH 占用数据库连接不释放问题
SSH框架的项目在訪问数据库的时候.訪问完毕后一直占用链接,不释放.导致过了一段时间后,server没挂,就是有訪问数据库的连接是时候.一直卡住 解决的方法: 1.配置spring相应的hiber ...
- 在vi或vim上查找字符串
从开头搜索 在命令模式下,输入/你要查找的字符 按下回车,可以看到vim把光标移动到该字符处 再按n(小写)查看下一个匹配 按N(大写)查看上一个匹配, capslock切换大小写,也可以在小写状态下 ...
- php......房屋租赁练习
多条件查询搜索页面,提交到当前页面处理 <?php include("../DB.class.php"); $db = new DB(); /*var_dump($_POST ...
- 【leetcode刷题笔记】Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...
- python学习笔记20160413
1. type(val) #查看val的类型. 2. 出现错误的时候, 读懂错误信息.3. raw_input('xxx') #读取用户输入都是string类型数据.4. ValueError: in ...
- 用css完成根据子元素不同书写样式
我们需要达到的效果: 需要什么 1张图片的, 2张图片的, 3张图片的样式各不相同.可以使用js完成子元素的判断,但是这里我使用css来完成 核心知识点 使用css选择器完成子元素的判断 例子: 用c ...
- day4 内置函数 迭代器&生成器 yield总结 三元运算 闭包
内置函数: 内置函数 # abs()返回一个数字的绝对值.如果给出复数,返回值就是该复数的模. b = -100 print(b) print(abs(b)) # all() 所有为真才为真,只要有一 ...
- Spring Cloud2.0之整合Consul作为注册中心
使用Consul来替换Eureka Consul简介 Consul 是一套开源的分布式服务发现和配置管理系统,由 HashiCorp 公司用 Go 语言开发. 它具有很多优点.包括: 基于 raft ...