随笔分类 -  OnlineJudge

摘要:LRU Cache题目链接:https://oj.leetcode.com/problems/lru-cache/Design and implement a data structure for Least Recently Used (LRU) cache. It should support ... 阅读全文
posted @ 2014-05-23 15:57 Matrix海子 阅读(62841) 评论(9) 推荐(10) 编辑
摘要:Evaluate Reverse Polish Notation题目链接:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/ Evaluate the value of an arithmetic expression... 阅读全文
posted @ 2014-05-05 10:15 Matrix海子 阅读(6785) 评论(0) 推荐(0) 编辑
摘要:Reverse Words in a String题目链接:http://oj.leetcode.com/problems/reverse-words-in-a-string/ Given an input string, reverse the string word by word. F... 阅读全文
posted @ 2014-04-29 20:22 Matrix海子 阅读(4027) 评论(0) 推荐(1) 编辑
摘要:Repository Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1129Accepted Submission(s): 382Problem DescriptionWhen you go shopping, you can search in repository for avalible merchandises by the computers and i... 阅读全文
posted @ 2011-10-18 10:57 Matrix海子 阅读(1762) 评论(0) 推荐(0) 编辑
摘要:Hat’s Words Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2414Accepted Submission(s): 880Problem DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictiona... 阅读全文
posted @ 2011-10-16 17:56 Matrix海子 阅读(2885) 评论(0) 推荐(0) 编辑
摘要:Phone List Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3544Accepted Submission(s): 1191Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the pr... 阅读全文
posted @ 2011-10-15 23:16 Matrix海子 阅读(4624) 评论(2) 推荐(1) 编辑
摘要:Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4318Accepted Submission(s): 1393Problem DescriptionIn the year 8888, the Earth is ruled by the PPF Empire . As the population growing , PPF needs to... 阅读全文
posted @ 2011-10-12 20:29 Matrix海子 阅读(2000) 评论(0) 推荐(1) 编辑
摘要:统计难题 Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 131070/65535 K (Java/Others) Total Submission(s): 7635Accepted Submission(s): 2972Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行... 阅读全文
posted @ 2011-10-12 09:01 Matrix海子 阅读(1357) 评论(0) 推荐(0) 编辑
摘要:Longest Ordered SubsequenceTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 18853Accepted: 8147DescriptionA numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 < 阅读全文
posted @ 2011-07-09 23:19 Matrix海子 阅读(3057) 评论(0) 推荐(0) 编辑
摘要:BlueEyes' ProblemThe Problem袁源在学英语的时候遇到了一个难题。当他看到一个单词的时候,他不知道这个词他以前是否背过。(这种事也常发生在其他人身上)。为了解决这个问题,他想在读某篇文章之前,先统计这篇文章中每个单词出现的次数。如果是你,你会怎么实现'统计'这个过程呢? 输入本题只有一组数据.输入为一篇不换行的英语文章(包括各种常用符号,长度小于10000个字母).'单词'在这里定义为只包含52个大小写字母的连续字符串(大写和小写是不同的字母,每个单词的长度不超过100,整个文章总共的单词数不超过1000个,如I'll是两 阅读全文
posted @ 2011-04-16 16:30 Matrix海子 阅读(898) 评论(0) 推荐(1) 编辑
摘要:1075: BlueEyes and Apples (II)The Problem袁源除了喜欢吃苹果外,他在有空的时候还喜欢把苹果按重量由大到小排成一列.当然,这是为了方便以后从最大的开始吃,这样他就能永远都吃到最大的!但是他只有一部没有砝码的天平,于是他每次只能比较两个苹果的重量。现在就要请你帮忙,如果每次只给出两个苹果的重量关系,怎样才能把这些苹果都排列好呢?输入本题包括多组测试数据.每组测试数据的第一行为一个整数n(1<=n<=20),代表一共的比较次数,接下来的n行,每行包括两个大写字母x和y,代表x的重量大于y.当n=0时代表输入结束,这组数据不包括在需要计算的数据中. 阅读全文
posted @ 2011-04-16 09:04 Matrix海子 阅读(772) 评论(0) 推荐(1) 编辑
摘要:Humble NumbersA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.Write a program to find and print the nth element in this sequence.Input SpecificationT. 阅读全文
posted @ 2011-04-15 10:00 Matrix海子 阅读(2420) 评论(0) 推荐(0) 编辑
摘要:IP判断基于Internet的程序中,我们常常需要判断一个IP字符串的合法性。合法的IP是这样的形式:A.B.C.D其中A、B、C、D均为位于[0, 255]中的整数。为了简单起见,我们规定这四个整数中不允许有前导零存在,如001这种情况。现在,请你来完成这个判断程序吧^_^Input输入由多行组成,每行是一个字符串,输入由“End of file”结束。字符串长度最大为30,且不含空格和不可见字符。Output对于每一个输入,单独输出一行如果该字符串是合法的IP,输出YES,否则,输出NOSample Input202.115.32.24a.b.c.dSample OutputYESNO题. 阅读全文
posted @ 2011-04-13 18:53 Matrix海子 阅读(1779) 评论(0) 推荐(0) 编辑
摘要:dance2Time Limit: 3000 MS Memory Limit: 65536 K DescriptionThe cow cotillion, a fancy dance every spring, requires the cows(shown as ">") and bulls (shown as "<") to bow to each other duringa dance. Schematically, one properly bowing pair of cattle is shownlike this: " 阅读全文
posted @ 2011-04-11 21:31 Matrix海子 阅读(527) 评论(0) 推荐(0) 编辑