PAT
风 先生
这个作者很懒,什么都没留下…
展开
-
Solution of 1144 The Missing Number (20)
1144 The Missing Number (20)Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For...原创 2018-05-19 00:10:49 · 291 阅读 · 0 评论 -
solution Of 1091. Acute Stroke (30)
1091. Acute Stroke (30)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI s原创 2016-06-17 22:54:39 · 324 阅读 · 0 评论 -
solution Of 1096. Consecutive Factors (20)
1096. Consecutive Factors (20)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three co原创 2016-06-17 16:28:02 · 390 阅读 · 0 评论 -
solution Of 1103. Integer Factorization (30)
1103. Integer Factorization (30)The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P fact原创 2016-06-16 23:04:25 · 422 阅读 · 0 评论 -
solution Of 1101. Quick Sort (25)
1101. Quick Sort (25)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot原创 2016-06-16 00:01:36 · 473 阅读 · 0 评论 -
solution Of 1107. Social Clusters (30)
1107. Social Clusters (30)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 “social cluster” is a set of p原创 2016-06-15 17:07:15 · 457 阅读 · 0 评论 -
solution Of 1102. Invert a Binary Tree (25)
1102. Invert a Binary Tree (25)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck o原创 2016-06-14 01:26:54 · 330 阅读 · 0 评论 -
solution Of 1106. Lowest Price in Supply Chain (25)
1106. Lowest Price in Supply Chain (25)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone involved in moving a product from supplier to customer.Starting fro原创 2016-06-12 17:54:47 · 338 阅读 · 0 评论 -
solution Of 1104. Sum of Number Segments (20)
1104. Sum of Number Segments (20)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (原创 2016-06-12 16:13:53 · 366 阅读 · 0 评论 -
solution Of 1069. The Black Hole of Numbers (20)
1069. The Black Hole of Numbers (20)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-decreasing order, a原创 2016-06-12 15:48:40 · 337 阅读 · 0 评论 -
solution Of 1095. Cars on Campus (30)
1095. Cars on Campus (30)Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the info原创 2016-06-24 14:11:09 · 537 阅读 · 0 评论 -
solution Of 1019. General Palindromic Number (20)
1019. General Palindromic Number (20)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single d原创 2016-06-19 20:32:54 · 342 阅读 · 0 评论 -
solution Of 1051. Pop Sequence (25)
1051. Pop Sequence (25)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possib原创 2016-06-19 23:10:10 · 285 阅读 · 0 评论 -
Solution of 1122. Hamiltonian Cycle (25)
1122. Hamiltonian Cycle (25)The “Hamilton cycle problem” is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a “Hamiltonian cycle”.In this problem, you are supp...原创 2018-04-23 01:52:13 · 245 阅读 · 0 评论 -
Solution of 1119. Pre- and Post-order Traversals (30)
1119. Pre- and Post-order Traversals (30)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder trave原创 2016-09-16 01:11:01 · 826 阅读 · 1 评论 -
Solution of 1118. Birds in Forest (25)
1118. Birds in Forest (25)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the sci原创 2016-09-15 21:33:35 · 294 阅读 · 0 评论 -
Solution of 1117. Eddington Number(25)
1117. Eddington Number(25)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an “Eddington number”, E – that is, the maximum integer原创 2016-09-13 12:03:57 · 1040 阅读 · 0 评论 -
solution Of 1116. Come on! Let's C (20)
1116. Come on! Let’s C (20)“Let’s C” is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, th原创 2016-09-12 10:45:32 · 676 阅读 · 0 评论 -
solution Of 1014. Waiting in Line (30)
1014. Waiting in Line (30)Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wai原创 2016-06-22 12:31:37 · 730 阅读 · 0 评论 -
solution Of 1055. The World's Richest (25)
1055. The World’s Richest (25)Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but原创 2016-06-22 02:04:08 · 429 阅读 · 0 评论 -
solution Of 1066. Root of AVL Tree (25)
1066. Root of AVL Tree (25)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 time they differ by mor原创 2016-06-21 15:16:34 · 398 阅读 · 0 评论 -
solution Of 1018. Public Bike Management (30)
1018. Public Bike Management (30)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return原创 2016-07-06 16:50:09 · 543 阅读 · 0 评论 -
solution Of 1022. Digital Library (30)
1022. Digital Library (30)A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned a原创 2016-06-20 22:49:42 · 484 阅读 · 0 评论 -
solution Of 1105. Spiral Matrix (25)
1105. Spiral Matrix (25) This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-原创 2016-04-24 23:41:06 · 321 阅读 · 0 评论 -
solution Of 1098. Insertion or Heap Sort (25)
1098. Insertion or Heap Sort (25)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes on原创 2016-05-18 11:27:51 · 299 阅读 · 0 评论 -
solution Of 1029. Median (25)
1029. Median (25)Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16原创 2016-05-17 16:14:04 · 325 阅读 · 0 评论 -
solution Of Pat 1110. Complete Binary Tree (25)
1110. Complete Binary Tree (25) Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a原创 2016-03-15 12:03:59 · 1503 阅读 · 0 评论 -
solution Of Pat 1109. Group Photo (25)
1109.Group Photo (25)Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:The number of people in each row must be N/K (round down to原创 2016-03-15 00:43:14 · 1039 阅读 · 0 评论 -
solution Of Pat 1115. Counting Nodes in a BST (30)
1115. Counting Nodes in a BST (30)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 with keys less tha原创 2016-03-24 20:47:35 · 798 阅读 · 1 评论 -
solution Of Pat1108. Finding Average (20)
1108. Finding Average (20) The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be leg原创 2016-03-14 12:55:02 · 802 阅读 · 0 评论 -
solution Of Pat 1114. Family Property (25)
1114. Family Property (25)This time, you are supposed to help us collect the data for family-owned property. Given each person’s family members, and the estate(房产)info under his/her own name, we need t原创 2016-03-24 16:49:44 · 926 阅读 · 0 评论 -
solution Of Pat 1099. Build A Binary Search Tree (30)
1099. Build A Binary Search Tree (30)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 with keys less原创 2016-04-04 01:54:36 · 311 阅读 · 0 评论 -
solution Of Pat 1113. Integer Set Partition (25)
1113. Integer Set Partition (25)Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote th原创 2016-03-16 21:08:51 · 640 阅读 · 0 评论 -
1097. Deduplication on a Linked List (25)
Deduplication on a Linked List (25) Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only th原创 2015-08-13 18:21:44 · 564 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25)
Highest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone involved in moving a product from supplier to customer.Starting from o原创 2015-08-13 20:10:26 · 543 阅读 · 0 评论 -
1086.Tree Traversals Again
Tree Traversals Again (25) An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 t原创 2015-08-10 13:26:55 · 345 阅读 · 0 评论 -
solution Of Pat 1111. Online Map (30)
1111. Online Map (30)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is原创 2016-03-15 17:50:43 · 2285 阅读 · 0 评论 -
solution Of Pat 1021. Deepest Root (25)
1021. Deepest Root (25)A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a high原创 2016-03-26 17:01:53 · 458 阅读 · 0 评论 -
solution Of 1087. All Roads Lead to Rome (30)
1087. All Roads Lead to Rome (30)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 gaining the most happine原创 2016-05-17 12:17:54 · 658 阅读 · 0 评论 -
solution Of 1025. PAT Ranking (25)
1025. PAT Ranking (25)Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places原创 2016-05-17 01:39:56 · 302 阅读 · 0 评论