PAT刷题笔记
文章平均质量分 88
柴郡猫的耳朵尖
要好好写代码吖
展开
-
1018 Public Bike Management (30 point(s)) PAT(AVL树,层序遍历,完全二叉树)
1018 Public Bike Management (30 point(s))☆AVL树,层序遍历,完全二叉树题目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 more than one, rebalanc原创 2022-03-02 14:39:18 · 265 阅读 · 0 评论 -
1118 Birds in Forest (25 point(s)) PAT(并查集)
1118 Birds in Forest (25 point(s))并查集题目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 scientists to count the maximum number of原创 2022-03-01 16:58:17 · 180 阅读 · 0 评论 -
1156 Sexy Primes (20 point(s)) PAT 素数
1156 Sexy Primes (20 point(s))素数题目“Forever number” is a positive integer A with K digits, satisfying the following constrains:the sum of all the digits of A is m;the sum of all the digits of A+1 is n; andthe greatest common divisor of m and n is a pr原创 2022-02-25 17:33:09 · 396 阅读 · 0 评论 -
1160 Forever (20 point(s))
1160 Forever (20 point(s))☆题目“Forever number” is a positive integer A with K digits, satisfying the following constrains:the sum of all the digits of A is m;the sum of all the digits of A+1 is n; andthe greatest common divisor of m and n is a prime n原创 2022-02-20 14:42:30 · 554 阅读 · 0 评论 -
1162 Postfix Expression (25 point(s)) PAT
1162 Postfix Expression (25 point(s))☆题目Given a syntax tree (binary), you are supposed to output the corresponding postfix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains one test c原创 2022-02-20 14:07:14 · 147 阅读 · 0 评论 -
1161 Merging Linked Lists (25 point(s)) PAT
1161 Merging Linked Lists (25 point(s))题目Given two singly linked lists L1=a1→a2→⋯→an−1→anL_1=a_1→a_2→⋯→a_{n−1}→a_nL1=a1→a2→⋯→an−1→an and L2=b1→b2→⋯→bm−1→bmL_2=b_1→b_2→⋯→b_{m−1}→b_mL2=b1→b2→⋯→bm−1→bm. If n≥2m, you are supposed to reverse and mer原创 2022-02-20 13:49:43 · 1081 阅读 · 0 评论 -
1163 Dijkstra Sequence (30 point(s)) PAT
1163 Dijkstra Sequence (30 point(s))☆题目Dijkstra’s algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from one particular source vertex to all the other ver原创 2022-02-19 20:45:27 · 718 阅读 · 1 评论 -
1167 Cartesian Tree (30 point(s)) PAT甲级
1167 Cartesian Tree (30 point(s))题目A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of原创 2022-02-09 22:15:36 · 182 阅读 · 0 评论 -
1166 Summit (25 point(s)) PAT甲级
1166 Summit (25 point(s))题目A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone原创 2022-02-09 22:05:03 · 465 阅读 · 0 评论 -
1165 Block Reversing (25 point(s)) PAT甲级
1165 Block Reversing (25 point(s))题目Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the bloc原创 2022-02-08 13:15:03 · 287 阅读 · 0 评论 -
1164 Good in C (20 point(s)) PAT甲级
1164 Good in C (20 point(s))字符串题目When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?Input Specification:Each input file contains one test case. For each case, the first part gives the 26 capital En原创 2022-02-05 15:54:45 · 349 阅读 · 0 评论 -
1060 Are They Equal (25 point(s)) PAT甲级
1060 Are They Equal (25 point(s))字符串题目If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. Now given the number of significant digits on a原创 2021-05-10 20:47:05 · 62 阅读 · 0 评论 -
1056 Mice and Rice (25 point(s)) PAT甲级
1056 Mice and Rice (25 point(s))排序题目Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in o原创 2021-05-06 23:09:52 · 97 阅读 · 0 评论 -
1080 Graduate Admission (30 point(s)) PAT甲级
1080 Graduate Admission (30 point(s))排序题目It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.原创 2021-05-05 16:21:45 · 102 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 point(s)) PAT甲级
1079 Total Sales of Supply Chain (25 point(s))dfs题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the c原创 2021-05-02 17:26:27 · 150 阅读 · 0 评论 -
1078 Hashing (25 point(s)) PAT甲级
1078 Hashing (25 point(s))hash题目The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSize where TSize is the原创 2021-04-25 09:27:15 · 90 阅读 · 0 评论 -
1077 Kuchiguse (20 point(s)) PAT甲级
1077 Kuchiguse (20 point(s))字符串题目The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preference is called “Kuchiguse” and is o原创 2021-04-24 15:54:27 · 68 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30 point(s)) PAT甲级
1099 Build A Binary Search Tree (30 point(s))BST,树的遍历题目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 than the node’s key.The right s原创 2021-04-22 16:19:28 · 75 阅读 · 0 评论 -
1098 Insertion or Heap Sort (25 point(s)) PAT甲级
1098 Insertion or Heap Sort (25 point(s))插入排序、堆排序题目According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, fi原创 2021-04-22 14:51:30 · 66 阅读 · 0 评论 -
1097 Deduplication on a Linked List (25 point(s)) PAT甲级
1097 Deduplication on a Linked List (25 point(s))链表题目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 the first node of which the value or a原创 2021-04-20 19:48:56 · 98 阅读 · 0 评论 -
1094 The Largest Generation (25 point(s)) PAT甲级
1094 The Largest Generation (25 point(s))DFSA 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 the generation with the largest population.Input Specificati原创 2021-04-18 08:57:21 · 64 阅读 · 0 评论 -
1091 Acute Stroke (30 point(s)) PAT甲级
1091 Acute Stroke (30 point(s))BFS题目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 slice, your job is to calculate the volu原创 2021-04-17 10:07:19 · 124 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25 point(s)) PAT甲级
1090 Highest Price in Supply Chain (25 point(s))DFS题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the原创 2021-04-16 15:32:55 · 129 阅读 · 0 评论 -
1096 Consecutive Factors (20 point(s)) PAT甲级
1096 Consecutive Factors (20 point(s))题目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 consecutive numbers. Now given any positive N原创 2021-04-16 14:34:45 · 67 阅读 · 0 评论 -
1087 All Roads Lead to Rome (30 point(s)) PAT甲级
1087 All Roads Lead to Rome (30 point(s))Dijkstra+DFS题目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 happiness.Input Specification:Each原创 2021-04-14 12:00:30 · 133 阅读 · 0 评论 -
1114 Family Property (25 point(s)) PAT甲级
1114 Family Property (25 point(s))并查集题目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 to know the size of each family, and the原创 2021-04-13 20:15:00 · 97 阅读 · 0 评论 -
1113 Integer Set Partition (25 point(s)) PAT甲级
1113 Integer Set Partition (25 point(s))非常简单题目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 the sums of all the numbers in A1 and原创 2021-04-13 20:10:22 · 95 阅读 · 0 评论 -
1112 Stucked Keyboard (20 point(s)) PAT甲级
1112 Stucked Keyboard (20 point(s))字符串题目On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.Now given a resulting string on原创 2021-04-13 20:09:19 · 75 阅读 · 0 评论 -
1018 Public Bike Management (30 point(s)) PAT甲级
1018 Public Bike Management (30 point(s))DFS+剪枝题目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 it to any other stations in the city原创 2021-04-13 20:02:38 · 71 阅读 · 0 评论