![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT甲级
文章平均质量分 77
Axelrod Wayne
这个作者很懒,什么都没留下…
展开
-
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 than the node’s key.The right subtree of a node con原创 2021-05-02 17:45:16 · 94 阅读 · 0 评论 -
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 scientists to count the maximum number of trees in the fo原创 2021-01-11 19:01:35 · 56 阅读 · 0 评论 -
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 people who have some of their hobbies in common. You are原创 2021-01-11 18:25:09 · 64 阅读 · 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 high原创 2021-01-11 16:38:08 · 61 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25分)
1145 Hashing - Average Search Time (25分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average search time (the n原创 2020-08-03 21:16:16 · 113 阅读 · 0 评论 -
1137 Final Grading (25分)
1137 Final Grading (25分)For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignm原创 2020-08-03 20:30:51 · 147 阅读 · 0 评论 -
1078 Hashing (25分)
1078 Hashing (25分)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 maximum size of原创 2020-08-03 20:03:15 · 118 阅读 · 0 评论 -
1149 Dangerous Goods Packaging (25分)
1149 Dangerous Goods Packaging (25分)When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed原创 2020-08-03 19:36:09 · 142 阅读 · 0 评论 -
1063 Set Similarity (25分)
1063 Set Similarity (25分)Given two sets of integers, the similarity of the sets is defined to be Nc /Nt ×100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct numbers in the tw原创 2020-08-03 19:10:25 · 110 阅读 · 0 评论 -
1048 Find Coins (25分)
1048 Find Coins (25分)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 could accept all kinds of coins as payments. However, there was a special requirement o原创 2020-08-03 18:37:36 · 127 阅读 · 0 评论 -
1128 N Queens Puzzle (20分)
1128 N Queens Puzzle (20分)The “eight queens puzzle” is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. The eigh原创 2020-08-03 18:17:50 · 109 阅读 · 0 评论 -
1129 Recommendation System (25分)
1129 Recommendation System (25分)Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user’s preference by the number of times that an item has been原创 2020-08-03 17:36:01 · 232 阅读 · 0 评论 -
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 the nearest integer), with all the extra people (if原创 2020-08-02 11:14:01 · 152 阅读 · 0 评论 -
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 Sp原创 2020-08-01 14:03:20 · 81 阅读 · 0 评论 -
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(圣人)”; be原创 2020-08-01 13:30:25 · 97 阅读 · 0 评论 -
1056 Mice and Rice (25分)
1056 Mice and Rice (25分)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 order to become原创 2020-08-01 11:23:06 · 98 阅读 · 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原创 2020-08-01 10:36:44 · 88 阅读 · 0 评论 -
1047 Student List for Course (25分)
1047 Student List for Course (25分)Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:Each inp原创 2020-08-01 10:27:41 · 94 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分)
1007 Maximum Subsequence Sum (25分)Given a sequence of K integers { N1, N2 , …, NK }. A continuous subsequence is defined to be { Ni , Ni+1 , …, Nj } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the large原创 2020-07-29 13:45:37 · 86 阅读 · 0 评论 -
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 pivot原创 2020-07-29 12:17:41 · 86 阅读 · 0 评论 -
1093 Count PAT‘s (25分) 含DP做法
1093 Count PAT’s (25分)The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given any string, you are supposed原创 2020-07-28 11:13:23 · 100 阅读 · 0 评论 -
1049 Counting Ones (30分)
1049 Counting Ones (30分)The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Input Spec原创 2020-07-07 11:08:27 · 91 阅读 · 0 评论 -
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 consecutive numbers. Now given any positive N, you are s原创 2020-07-06 20:15:59 · 79 阅读 · 0 评论 -
1081 Rational Sum (20分)
1081 Rational Sum (20分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in the nex原创 2020-07-06 19:10:47 · 106 阅读 · 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.Inpu原创 2020-07-06 11:10:23 · 84 阅读 · 0 评论 -
1020 Tree Traversals (25分)
1020 Tree Traversals (25分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tree.Input原创 2020-07-06 10:07:42 · 113 阅读 · 0 评论 -
1004 Counting Leaves (30分)
1004 Counting Leaves (30分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts with a line containing 0<N&原创 2020-07-05 22:51:07 · 89 阅读 · 0 评论 -
1089 Insert or Merge (25分)
1089 Insert or Merge (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 belongs原创 2020-07-05 15:30:45 · 106 阅读 · 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原创 2020-07-05 15:03:15 · 132 阅读 · 0 评论 -
1075 PAT Judge (25分)
1075 PAT Judge (25分)The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file contains one test case. For each case,原创 2020-07-05 10:08:20 · 69 阅读 · 0 评论 -
1052 Linked List Sorting (25分)
1052 Linked List Sorting (25分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are原创 2020-07-04 10:37:04 · 98 阅读 · 0 评论 -
1039 Course List for Student (25分)
1039 Course List for Student (25分)Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.Input Sp原创 2020-07-04 10:08:45 · 95 阅读 · 0 评论 -
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, where原创 2020-07-04 09:51:56 · 275 阅读 · 1 评论 -
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 t原创 2020-07-03 22:09:11 · 74 阅读 · 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 fro原创 2020-07-03 21:13:05 · 99 阅读 · 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 enco原创 2020-07-03 19:33:10 · 115 阅读 · 0 评论 -
1152 Google Recruitment (20分)
1152 Google Recruitment (20分)In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL cons...原创 2020-04-09 22:10:15 · 142 阅读 · 0 评论 -
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 e...原创 2020-04-09 21:56:28 · 99 阅读 · 0 评论 -
1140 Look-and-say Sequence (20分)
1140 Look-and-say Sequence (20分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a ki...原创 2020-04-09 21:44:46 · 86 阅读 · 0 评论 -
1136 A Delayed Palindrome (20分)
1136 A Delayed Palindrome (20分)Consider a positive integer N written in standard notation with k+1 digits ai as ak ⋯a1 a0 with 0≤ai <10 for all i and ak >0. Then N is palindr...原创 2020-04-09 21:36:10 · 113 阅读 · 0 评论