![](https://img-blog.csdnimg.cn/20210212181343264.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT甲级
文章平均质量分 79
刷PAT甲级题库时的一些心得体会
2000nmj
啊
展开
-
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 off.Now it’s your turn to prove that YOU CAN invert原创 2021-03-06 16:32:14 · 47 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25 分)
1090 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 one root supplier, everyone on the chain buys pr原创 2021-03-06 15:09:08 · 81 阅读 · 0 评论 -
1053 Path of Equal Weight (30 分)
1053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti . The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R to any leaf node原创 2021-03-06 10:45:11 · 57 阅读 · 0 评论 -
1061 Dating (20 分)
1061 Dating (20 分)Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the coded原创 2021-03-04 20:51:17 · 77 阅读 · 1 评论 -
1035 Password (20 分)
1035 Password (20 分)To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (原创 2021-03-04 20:12:41 · 82 阅读 · 1 评论 -
1153 Decode Registration Card of PAT (25 分)
1153 Decode Registration Card of PAT (25 分)A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;the 2nd - 4th digits are the test site number, ranged f原创 2021-03-04 15:24:39 · 98 阅读 · 1 评论 -
1125 Chain the Ropes (25 分)
1125 Chain the Ropes (25 分)Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chain will be treated as another原创 2021-03-04 11:53:25 · 84 阅读 · 2 评论 -
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 the sums of all the numbers i原创 2021-03-04 10:53:55 · 87 阅读 · 1 评论 -
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 are moved to its left and those larger than the pivo原创 2021-03-04 09:38:58 · 59 阅读 · 1 评论 -
1083 List Grades (25 分)
1083 List Grades (25 分)Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Input S原创 2021-03-03 23:30:29 · 77 阅读 · 1 评论 -
1080 Graduate Admission (30 分)
1080 Graduate Admission (30 分)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.Each applican原创 2021-03-03 23:16:27 · 43 阅读 · 1 评论 -
1062 Talent and Virtue (25 分)
1062 Talent and Virtue (25 分)About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people’s talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a “sage(圣人)”; b原创 2021-03-03 17:32:07 · 60 阅读 · 1 评论 -
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 concentrate only on the people in a certain range of原创 2021-03-03 16:47:14 · 81 阅读 · 1 评论 -
1028 List Sorting (25 分)
1028 List Sorting (25 分)Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two integers N (≤10^5 ) and C, whe原创 2021-03-03 15:59:41 · 60 阅读 · 0 评论 -
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, and the ranklists will be merged immediately after原创 2021-03-03 11:13:07 · 43 阅读 · 0 评论 -
1016 Phone Bills (25 分)
1016 Phone Bills (25 分)A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a l原创 2021-03-03 08:34:56 · 100 阅读 · 0 评论 -
1012 The Best Rank (25 分)
1012 The Best Rank (25 分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we enc原创 2021-03-02 13:15:14 · 49 阅读 · 0 评论 -
1144 The Missing Number
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 each case, the first line gives a positive integer N (≤1原创 2021-03-02 10:53:55 · 52 阅读 · 0 评论 -
1141 PAT Ranking of Institutions (25 分)
1141 PAT Ranking of Institutions (25 分)After each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist.Input Specification:Each input file contains one test case.原创 2021-03-02 10:46:17 · 119 阅读 · 0 评论 -
1124 Raffle for Weibo Followers (20 分)
1124 Raffle for Weibo Followers (20 分)John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo – that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now y原创 2021-02-28 23:37:22 · 80 阅读 · 0 评论 -
1112 Stucked Keyboard (20 分)
1112 Stucked Keyboard (20 分)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 screen, you ar原创 2021-02-28 22:58:59 · 58 阅读 · 0 评论 -
1154 Vertex Coloring (25 分)
1154 Vertex Coloring (25 分)A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k-coloring.Now you are suppo原创 2021-02-28 16:55:02 · 40 阅读 · 0 评论 -
1100 Mars Numbers (20 分)
1100 Mars Numbers (20 分)People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively.For the next higher原创 2021-02-28 16:14:56 · 67 阅读 · 0 评论 -
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 one element from the input data, finds the location it原创 2021-02-28 12:43:31 · 120 阅读 · 0 评论 -
1095 Cars on Campus (30 分)
1095 Cars on Campus (30 分)Zhejiang University has 8 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 information available, you are supposed to tell, at any s原创 2021-02-27 23:17:53 · 310 阅读 · 0 评论 -
1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分)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 with the largest proportional area is called the dominant color. A strictly原创 2021-02-27 10:28:13 · 84 阅读 · 0 评论 -
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 an unique 7-digit number as its ID. Given any query fr原创 2021-02-26 23:23:49 · 55 阅读 · 0 评论 -
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 highest tree. Such a root is called the deepest root.Inp原创 2021-02-25 11:41:29 · 77 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)
1013 Battle Over Cities (25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other hig原创 2021-02-24 22:02:18 · 102 阅读 · 0 评论 -
1131 Subway Map (30 分)
1131 Subway Map (30 分)In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with your computer skills! Given the star原创 2021-02-24 20:33:27 · 126 阅读 · 0 评论 -
1130 Infix Expression (25 分)-PAT甲级真题
1130 Infix Expression (25 分)Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains one test case. For each ca原创 2021-02-19 16:47:06 · 89 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 分)
1127 ZigZagging on a Tree (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 traversal sequences. And it is a simple standard routine to print th原创 2021-02-19 11:50:16 · 77 阅读 · 0 评论 -
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 from one root supplier, everyone on the chain buys pro原创 2021-02-18 20:53:00 · 70 阅读 · 0 评论 -
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 factorization of N for any positive integers N, K and P.原创 2021-02-18 17:10:28 · 111 阅读 · 0 评论 -
1094 The Largest Generation (25 分)
1094 The Largest Generation (25 分)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 the generation with the largest population.Input Specification:Each in原创 2021-02-18 09:54:40 · 147 阅读 · 0 评论 -
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 slice, your job is to calculate the volume of the stro原创 2021-02-12 20:28:03 · 180 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 分)
1079 Total Sales of 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 one root supplier, everyone on the chain buys prod原创 2021-02-12 18:07:23 · 74 阅读 · 0 评论 -
1076 Forwards on Weibo (30 分)
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weibo, all his/her followers can vi原创 2021-02-12 15:58:39 · 76 阅读 · 2 评论 -
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 the fastest. It is guaranteed that a path exists for any request.Input Spec原创 2021-02-10 19:37:09 · 207 阅读 · 1 评论 -
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 happiness.Input Specification:Each input file contains one test case. For each case, the firs原创 2021-02-09 12:35:58 · 100 阅读 · 2 评论