
PAT (甲级) Practice
chen_zan_yu_
同是寒窗苦读,岂能甘拜下风
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1125 Chain the Ropes (25分)
1125Chain 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..原创 2020-05-12 23:34:53 · 250 阅读 · 0 评论 -
1119 Pre- and Post-order Traversals (30分)
1119Pre- 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 traversal sequences, or preorder and inorder traversal seq..原创 2020-05-11 20:57:35 · 224 阅读 · 0 评论 -
1133 Splitting A Linked List (25分)
1133Splitting A Linked List(25分)Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The orde..原创 2020-05-11 20:32:31 · 226 阅读 · 0 评论 -
1124 Raffle for Weibo Followers (20分)
1124Raffle 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 ..原创 2020-05-11 19:51:21 · 246 阅读 · 0 评论 -
1115 Counting Nodes in a BST (30分)
1115Counting 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 than or equal to the node's key. The right subtree of..原创 2020-05-10 20:44:30 · 229 阅读 · 0 评论 -
1118 Birds in Forest (25分)
1118Birds 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 f..原创 2020-05-10 19:59:38 · 261 阅读 · 0 评论 -
1117 Eddington Number (25分)
1117Eddington 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 integerEsuch that it is forEdays that one rides more th...原创 2020-05-10 19:40:11 · 238 阅读 · 0 评论 -
1114 Family Property (25分)
1114Family 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 to know the size of each family, and the average area ..原创 2020-05-09 19:56:27 · 235 阅读 · 0 评论 -
1142 Maximal Clique (25分)
1142Maximal Clique(25分)Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one more adjacent vertex. (Quoted fromht...原创 2020-05-09 19:33:15 · 259 阅读 · 0 评论 -
1111 Online Map (30分)
1111Online 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 ..翻译 2020-05-09 12:55:14 · 216 阅读 · 0 评论 -
1113 Integer Set Partition (25分)
1113Integer Set Partition(25分)Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA1andA2ofn1andn2numbers, respectively. LetS1andS2denote the sums of all the numbers inA1...原创 2020-05-09 00:11:06 · 190 阅读 · 0 评论 -
1122 Hamiltonian Cycle (25分)
1122Hamiltonian 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 supposed to tell if a given cycle is a Hamiltonian cycle.I..原创 2020-05-08 23:49:08 · 181 阅读 · 0 评论 -
1121 Damn Single (25分)
1121Damn Single(25分)"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input S...原创 2020-05-07 13:36:47 · 218 阅读 · 0 评论 -
1120 Friend Numbers (20分)
1120Friend Numbers(20分)Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3...原创 2020-05-07 12:53:52 · 234 阅读 · 0 评论 -
1152 Google Recruitment (20分)
1152Google 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 con...原创 2020-05-07 12:42:20 · 415 阅读 · 0 评论 -
1150 Travelling Salesman Problem (25分)
1150Travelling Salesman Problem(25分)The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possi...原创 2020-05-07 12:22:29 · 327 阅读 · 0 评论 -
1146 Topological Order (25分)
1146Topological Order(25分)This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are suppo...原创 2020-05-06 09:30:38 · 317 阅读 · 0 评论 -
1144 The Missing Number (20分)
1144The 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. Fo...原创 2020-05-06 08:57:39 · 210 阅读 · 0 评论 -
1128 N Queens Puzzle (20分)
1128N Queens Puzzle(20分)The "eight queens puzzle" is the problem of placing eight chess queens on an8×8chessboard so that no two queens threaten each other. Thus, a solution requires that no two...原创 2020-05-06 08:34:58 · 251 阅读 · 0 评论 -
1148 Werewolf - Simple Version (20分)
1148Werewolf - Simple Version(20分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Play...原创 2020-05-06 01:17:44 · 291 阅读 · 0 评论 -
1132 Cut Integer (20分)
1132Cut Integer(20分)Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B ...原创 2020-05-06 00:57:18 · 261 阅读 · 0 评论 -
1140 Look-and-say Sequence (20分)
1140Look-and-say Sequence(20分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...whereDis in [0, 9] except 1. The (n+1)st number is ...原创 2020-05-06 00:45:05 · 213 阅读 · 0 评论 -
1149 Dangerous Goods Packaging (25分)
1149Dangerous 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 troub...原创 2020-05-05 00:04:20 · 200 阅读 · 0 评论 -
1116 Come on! Let's C (20分)
1116Come 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,...原创 2020-05-03 23:59:26 · 181 阅读 · 0 评论 -
1112 Stucked Keyboard (20分)
1112Stucked 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...原创 2020-05-03 23:25:42 · 178 阅读 · 0 评论 -
1110 Complete Binary Tree (25分)
1110Complete 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 gi...原创 2020-05-02 16:42:22 · 264 阅读 · 0 评论 -
1105 Spiral Matrix (25分)
1105Spiral Matrix(25分)This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper...原创 2020-05-02 16:13:42 · 190 阅读 · 0 评论 -
1109 Group Photo (25分)
1109Group Photo(25分)Formation is very important when taking a group photo. Given the rules of formingKrows withNpeople as the following: The number of people in each row must beN/K(round ...原创 2020-05-02 15:43:52 · 455 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30分)
1127ZigZagging 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 se...原创 2020-04-30 19:51:39 · 234 阅读 · 0 评论 -
1108 Finding Average (20分)
1108Finding Average(20分)The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be le...原创 2020-04-28 19:14:41 · 285 阅读 · 0 评论 -
1147 Heaps (30分)
1147Heaps(30分)In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater t...原创 2020-04-28 18:31:03 · 232 阅读 · 0 评论 -
1153 Decode Registration Card of PAT (25分)
1153Decode Registration Card of PAT(25分)A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic...原创 2020-04-24 00:36:06 · 253 阅读 · 0 评论 -
1154 Vertex Coloring (25分)
1154Vertex Coloring(25分)Aproper vertex coloringis 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 mostkc...原创 2020-04-23 23:58:48 · 321 阅读 · 0 评论 -
1057 Stack (30分) [树状数组]
1057Stack(30分)Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the to...原创 2020-04-23 23:33:38 · 180 阅读 · 0 评论 -
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, 17 } is...原创 2020-04-21 23:48:17 · 209 阅读 · 0 评论 -
1092 To Buy or Not to Buy (20分)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel...原创 2020-04-21 23:35:38 · 195 阅读 · 0 评论 -
1026 Table Tennis (30分)
1026Table Tennis(30分)A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they wi...原创 2020-04-21 20:20:37 · 285 阅读 · 0 评论 -
1098 Insertion or Heap Sort (25 分)
1098Insertion or Heap Sort(25分)According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remo...原创 2019-12-01 20:37:49 · 117 阅读 · 0 评论 -
1107 Social Clusters (30 分)
1107Social 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. Asocial clusteris a set of...原创 2019-12-01 19:26:28 · 151 阅读 · 0 评论 -
1066 Root of AVL Tree (25 分)
1066Root 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...原创 2019-11-09 15:48:28 · 184 阅读 · 0 评论