Description There is a robot, its task is to bury treasures in order on a N × M grids map, and each treasure can be represented by its weight, which is an integer. The robot begins to bury the treasures from the top-left grid. Because it is stupid, i…
Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., n-1 respectively. The leaf 0 and n-1 are adjacent. The frog king wants to play a jumping game. He stands at the leaf 0 initially. For each move, he j…
Description Given a m × n chessboard, a stone is put on the top-left corner (1, 1). Kevin and Bob take turns moving the stone. One can only move the stone one block right or downward and cannot stay in the same block. Kevin goes first and the one who…
Description Given a string S, which consists of lowercase characters, you need to find the longest palindromic sub-string. A sub-string of a string S is another string S' that occurs "in" S. For example, "abst" is a sub-string of "…
Description Given n numbers, your task is to insert '+' or '-' in front of each number to construct expressions. Note that the position of numbers can be also changed. You can calculate a result for each expression. Please count the number of distinc…
Description Handoku is sailing on a lake at the North Pole. The lake can be considered as a two-dimensional square plane containing N × N blocks, which is shown in the form of string containing '*' and '#' on the map. : a normal block; : a block cont…
Description Corn does not participate the STEED contest, but he is interested in the word "STEED". So, Corn writes all permutations of the word "STEED" on different cards and gets 60 cards finally. Corn sorts these cards in lexicograph…