摘要: The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. A binary search tree (BST) i 阅读全文
posted @ 2019-03-08 21:02 Pure_Java 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 阅读全文
posted @ 2019-03-08 21:02 Pure_Java 阅读(360) 评论(0) 推荐(0) 编辑
摘要: Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×\times×5×\times×6×\t 阅读全文
posted @ 2019-03-08 21:00 Pure_Java 阅读(281) 评论(0) 推荐(0) 编辑
摘要: Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of b 阅读全文
posted @ 2019-03-08 20:58 Pure_Java 阅读(142) 评论(0) 推荐(0) 编辑
摘要: For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient. Input Sp 阅读全文
posted @ 2019-03-08 20:57 Pure_Java 阅读(239) 评论(0) 推荐(0) 编辑
摘要: On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on sc 阅读全文
posted @ 2019-03-08 20:54 Pure_Java 阅读(423) 评论(0) 推荐(0) 编辑
摘要: Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. Input Specification: Each input file contains one 阅读全文
posted @ 2019-03-08 20:42 Pure_Java 阅读(247) 评论(0) 推荐(0) 编辑
摘要: The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the s 阅读全文
posted @ 2019-03-08 20:40 Pure_Java 阅读(261) 评论(0) 推荐(0) 编辑
摘要: Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+- 阅读全文
posted @ 2019-03-08 20:39 Pure_Java 阅读(228) 评论(0) 推荐(0) 编辑
摘要: For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decre 阅读全文
posted @ 2019-03-08 20:38 Pure_Java 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Given three integers A, B and C in [−2​63​​,2​63​​], you are supposed to tell whether A+B>C. Input Specification: The first line of the input gives th 阅读全文
posted @ 2019-03-08 20:37 Pure_Java 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minut 阅读全文
posted @ 2019-03-08 20:36 Pure_Java 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color 阅读全文
posted @ 2019-03-08 20:35 Pure_Java 阅读(207) 评论(0) 推荐(0) 编辑
摘要: If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver 阅读全文
posted @ 2019-03-08 20:35 Pure_Java 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task 阅读全文
posted @ 2019-03-08 20:34 Pure_Java 阅读(289) 评论(0) 推荐(0) 编辑
摘要: The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of e 阅读全文
posted @ 2019-03-08 20:33 Pure_Java 阅读(320) 评论(0) 推荐(0) 编辑
摘要: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "ins 阅读全文
posted @ 2019-03-08 20:31 Pure_Java 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a numbe 阅读全文
posted @ 2019-03-08 20:29 Pure_Java 阅读(229) 评论(0) 推荐(0) 编辑
摘要: Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: That is, t 阅读全文
posted @ 2019-03-08 20:28 Pure_Java 阅读(385) 评论(0) 推荐(0) 编辑
摘要: People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, wher 阅读全文
posted @ 2019-03-08 20:27 Pure_Java 阅读(154) 评论(0) 推荐(0) 编辑