随笔分类 - PAT 甲级
摘要:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is
阅读全文
摘要:The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elev
阅读全文
摘要:This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file contains one test case. Each case occupies 2 lines, a
阅读全文
摘要:Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less t
阅读全文
摘要:Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest sym
阅读全文
摘要:Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which cou
阅读全文
摘要:Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off th
阅读全文
摘要:Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 <= i <= j <= K
阅读全文
摘要:Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gainin
阅读全文
摘要:A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as po
阅读全文
摘要:According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. At each iteration, ins
阅读全文
摘要:When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "soci
阅读全文
摘要:An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any
阅读全文
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes
阅读全文
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes
阅读全文
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes
阅读全文
摘要:Given a non-empty tree with root R, and with weight W~i~ assigned to each tree node T~i~. The weight of a path from R to L is defined to be the sum of
阅读全文
摘要:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contain
阅读全文
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer
阅读全文
摘要:A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find t
阅读全文