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 ...
随机推荐
- javascript中apply和call的区别
请补充 136页 pdf 高级javascript设计
- c#的const可以用于引用类型吗
答案是可以的.不过用const修饰的类实例只能是null. class A{ public int a=0; } class B{ const A constA=null; const object ...
- MediaRecorder实现微信、QQ、人人、易信等语音录制功能工具:MediaUtilAPI
本文介绍使用MediaRecorder进行录制音频.录制视频学习,熟悉MediaRecorder执行流程,通过简单的Demo结合解释运行效果,最后封装MediaRecorder的API工具,实现常见比 ...
- ubuntun下安装Fiddler
对于分析网页或者写爬虫的时候经常需要用到抓包工具进行网页数据的抓包.在Windows下可以安装Fiddler来抓包.在ubuntun下不能直接安装Fiddler.需要先安装mono 1 首先安装mon ...
- 显示HTML的版权符号
最近有小伙伴问©符号在页面显示很小,于是去查看他的源代码 他在HTML代码里对应输入© 那么在页面里应该会正常显示版权符号,可是为什么会出现这种问题呢? 首先我想到页面在设计的时候,用的字体是宋体,就 ...
- 运用starling开发的手游FlappyBird
最近想向游戏方面发展,于是用starling做了一个简易版的FlappyBird,纯AS3开发,权当是技术学习.在发布之后才明白要发布一个没有版权的app是有多困难,审核了N遍之后终于通过审核,下面发 ...
- Data Structure Array: Sort elements by frequency
http://www.geeksforgeeks.org/sort-elements-by-frequency-set-2/ #include <iostream> #include &l ...
- 为jquery添加扩展标准思路
jquery扩展分为对象扩展和jquery本身类扩展: 对象扩展: (function($){ $.fn.abc = function(){ console.log($(this).get(0)); ...
- 什么是gitlab CI ?CI代表什么?
CI是Continuous Integration的简称,就是持续集成的意思. 就是说你代码改动了,测试了,提交了,持续集成系统会自动构建(编译等等).持续集成的理念是每个提交的版本都应该是可交付的, ...
- 如何处理异常? catch Exception OR catch Throwable
在Java中,当你需要统一处理异常的时候,你是会选择catch (Exception),还是直接catch (Throwable)? Java的异常体系 Throwable: Java中所有异常和错误 ...