
pat
文章平均质量分 81
小庄同学
这个作者很懒,什么都没留下…
展开
-
【PAT甲级2020年春季考试】7-4 Replacement Selection (30分)(c++)
7-4 Replacement Selection (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBWhen the input is much too large to fit into memory, we have to do external sorting instead of internal sorting. One of the key steps in external sorting is to generat原创 2020-12-03 21:58:05 · 2729 阅读 · 0 评论 -
【PAT甲级2020年春季考试】7-3 Safari Park (25分)(c++)
7-3 Safari Park (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBA safari park(野生动物园)has K species of animals, and is divided into N regions. The managers hope to spread the animals to all the regions, but not the same animals in the two neig原创 2020-12-03 21:25:05 · 328 阅读 · 0 评论 -
【PAT甲级2020年春季考试】7-2 The Judger (25分)(c++)
7-2 The Judger (25分)A game of numbers has the following rules: at the beginning, two distinct positive integers are given by the judge. Then each player in turn must give a number to the judge. The number must be the difference of two numbers that are pre原创 2020-12-03 21:17:57 · 286 阅读 · 0 评论 -
【PAT甲级2020年春季考试】7-1 Prime Day (20分)(c++)
7-1 Prime Day (20分)The above picture is from Sina Weibo, showing May 23rd, 2019 as a very cool “Prime Day”. That is, not only that the corresponding number of the date 20190523 is a prime, but all its sub-strings ended at the last digit 3 are prime numbe原创 2020-12-03 21:02:20 · 231 阅读 · 0 评论 -
【PAT甲级A1155】Heap Paths (30分)(c++)
1155 Heap Paths (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBIn computer science, a heap is 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 grea原创 2020-12-03 20:57:14 · 140 阅读 · 0 评论 -
【PAT甲级A1154】Vertex Coloring (25分)(c++)
1154 Vertex Coloring (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBA 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 c原创 2020-12-03 20:49:47 · 143 阅读 · 0 评论 -
【PAT甲级A1153】Decode Registration Card of PAT (25分)(c++)
1153 Decode Registration Card of PAT (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBA 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;原创 2020-12-03 20:42:53 · 433 阅读 · 0 评论 -
【PAT甲级A1152】Google Recruitment (20分)(c++)
1152 Google Recruitment (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBIn 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-12-03 20:05:50 · 626 阅读 · 0 评论 -
【PAT甲级A1151】LCA in a Binary Tree (30分)(c++)
1151 LCA in a Binary Tree (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBThe lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are原创 2020-12-03 20:01:16 · 85 阅读 · 0 评论 -
【PAT甲级A1150】Travelling Salesman Problem (25分)(c++)
1150 Travelling Salesman Problem (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBThe “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-12-03 19:48:35 · 219 阅读 · 0 评论 -
【PAT甲级A1149】Dangerous Goods Packaging (25分)(c++)
1149 Dangerous Goods Packaging (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBWhen 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-12-03 10:08:47 · 173 阅读 · 0 评论 -
【PAT甲级A1148】Werewolf - Simple Version (20分)(c++)
1148 Werewolf - Simple Version (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBWerewolf(狼人杀) 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: “Playe原创 2020-12-03 09:49:55 · 238 阅读 · 0 评论 -
【PAT甲级A1147】Heaps (30分)(c++)
1147 Heaps (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBIn computer science, a heap is 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-12-03 09:35:50 · 184 阅读 · 0 评论 -
【PAT甲级A1146】Topological Order (25分)(c++)
1146 Topological Order (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBThis 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-12-03 09:27:27 · 147 阅读 · 0 评论 -
【PAT甲级A1145】Hashing - Average Search Time (25分)(c++)
1145 Hashing - Average Search Time (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBThe 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原创 2020-12-03 09:11:21 · 183 阅读 · 0 评论 -
【PAT甲级A1144】The Missing Number (20分)(c++)
1144 The Missing Number (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:200 ms内存限制:64 MBGiven 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原创 2020-12-03 08:41:38 · 177 阅读 · 0 评论 -
【PAT甲级A1143】 Lowest Common Ancestor (30分)(c++)
1143 Lowest Common Ancestor (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBThe lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively d原创 2020-12-03 08:35:14 · 148 阅读 · 0 评论 -
【PAT甲级A1142】 Maximal Clique (25分)(c++)
1142 Maximal Clique (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBA clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extende原创 2020-12-02 09:25:29 · 105 阅读 · 0 评论 -
【PAT甲级A1141】 PAT Ranking of Institutions (25分)(c++)
1141 PAT Ranking of Institutions (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBAfter each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist.Inpu原创 2020-12-02 09:16:37 · 129 阅读 · 0 评论 -
【PAT甲级A1140】 Look-and-say Sequence (20分)(c++)
1140 Look-and-say Sequence (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBLook-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 k原创 2020-12-02 08:53:47 · 113 阅读 · 0 评论 -
【PAT甲级A1138】 Postorder Traversal (25分)(c++)
1138 Postorder Traversal (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBSuppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first numb原创 2020-12-01 23:35:06 · 108 阅读 · 0 评论 -
【PAT甲级A1137】 Final Grading (25分)(c++)
1137 Final Grading (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBFor 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原创 2020-12-01 23:26:36 · 161 阅读 · 0 评论 -
【PAT甲级A1136】 A Delayed Palindrome (20分)(c++)
1136 A Delayed Palindrome (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBConsider 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 palin原创 2020-12-01 17:33:15 · 109 阅读 · 0 评论 -
【PAT甲级A1133】 Splitting A Linked List (25分)(c++)
1133 Splitting A Linked List (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBGiven 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原创 2020-12-01 12:10:19 · 167 阅读 · 0 评论 -
【PAT甲级A1132】 Cut Integer (20分)(c++)
1132 Cut Integer (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBCutting 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-12-01 11:01:09 · 106 阅读 · 0 评论 -
【PAT甲级A1130】 Infix Expression (25分)(c++)
1130 Infix Expression (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBGiven a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specificat原创 2020-11-29 15:02:03 · 177 阅读 · 0 评论 -
【PAT甲级A1129】 Recommendation System (25分)(c++)
1129 Recommendation System (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBRecommendation 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’原创 2020-11-29 13:54:53 · 194 阅读 · 0 评论 -
【PAT甲级A1128】 N Queens Puzzle (20分)(c++)
1128 N Queens Puzzle (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:300 ms内存限制:64 MBThe “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原创 2020-11-29 11:00:36 · 131 阅读 · 0 评论 -
【PAT甲级A1127】 ZigZagging on a Tree (30分)(c++)
1127 ZigZagging on a Tree (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBSuppose 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-11-29 10:23:55 · 584 阅读 · 0 评论 -
【PAT甲级A1126】 Eulerian Path (25分)(c++)
1126 Eulerian Path (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:300 ms内存限制:64 MBIn graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the s原创 2020-11-28 21:59:32 · 125 阅读 · 0 评论 -
【PAT甲级A1125】 Chain the Ropes (25分)(c++)
1125 Chain the Ropes (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:200 ms内存限制:64 MBGiven 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 th原创 2020-11-28 20:43:22 · 278 阅读 · 0 评论 -
【PAT甲级A1124】 Raffle for Weibo Followers (20分)(c++)
1124 Raffle for Weibo Followers (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBJohn 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 foll原创 2020-11-28 20:13:26 · 165 阅读 · 0 评论 -
【PAT甲级A1123】 Is It a Complete AVL Tree (30分)(c++)
1123 Is It a Complete AVL Tree (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBAn 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 d原创 2020-11-28 19:44:53 · 172 阅读 · 0 评论 -
【PAT甲级A1122】 Hamiltonian Cycle (25分)(c++)
1122 Hamiltonian Cycle (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:300 ms内存限制:64 MBThe “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 suppo原创 2020-11-28 19:36:43 · 526 阅读 · 0 评论 -
【PAT甲级A1121】 Damn Single (25分)(c++)
1121 Damn Single (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:200 ms内存限制:64 MB“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 Sp原创 2020-11-28 19:30:27 · 301 阅读 · 0 评论 -
【PAT甲级A1120】 Friend Numbers (20分)(c++)
1120 Friend Numbers (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBTwo 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-11-28 19:25:28 · 135 阅读 · 0 评论 -
【PAT甲级A1119】 Pre- and Post-order Traversals (30分)(c++)
1119 Pre- and Post-order Traversals (30分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:400 ms内存限制:64 MBSuppose 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 tr原创 2020-11-28 11:50:38 · 102 阅读 · 0 评论 -
【PAT甲级A1118】 Birds in Forest (25分)(c++)
1118 Birds in Forest (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:150 ms内存限制:64 MBSome 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原创 2020-11-28 09:37:11 · 154 阅读 · 0 评论 -
【PAT甲级A1117】 Eddington Number (25分)(c++)
1117 Eddington Number (25分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:250 ms内存限制:64 MBBritish 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 inte原创 2020-11-27 21:25:26 · 149 阅读 · 0 评论 -
【PAT甲级A1116】 Come on! Let‘s C (20分)(c++)
1116 Come on! Let’s C (20分)作者:CHEN, Yue单位:浙江大学代码长度限制:16 KB时间限制:200 ms内存限制:64 MB“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-11-27 21:01:10 · 169 阅读 · 0 评论