
PAT (Advanced Level) Practice
PAT (Advanced Level) Practice
Jason66661010
这个作者很懒,什么都没留下…
展开
-
PAT (Advanced Level) Practice 1015 Reversible Primes (20分) (进制转换+素数判断)
1.题目Areversible primein any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is als...原创 2020-04-25 21:36:08 · 124 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1013 Battle Over Cities (25分) (使用DFS对图的强连通分量的统计)
1.题目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 ...原创 2020-04-24 19:21:55 · 139 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1010 Radix (25分) (进制转换 longlong溢出 二分查找)
1.题目Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positiv...原创 2020-04-24 16:25:35 · 138 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1004 Counting Leaves (30分) (普通树的DFS)
1.题目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 ...原创 2020-04-24 15:23:08 · 134 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1071 Speech Patterns (25分)
1.题目People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a s...原创 2020-04-21 16:05:33 · 129 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1070 Mooncake (25分)
1.题目Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture...原创 2020-04-21 15:25:46 · 110 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1069 The Black Hole of Numbers (20分)
1.题目For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by...原创 2020-04-21 14:58:07 · 121 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1074 Reversing Linked List (25分)
1.题目Given a constantKand a singly linked listL, you are supposed to reverse the links of everyKelements onL. For example, givenLbeing 1→2→3→4→5→6, ifK=3, then you must output 3→2→1→6→5→4; i...原创 2020-04-17 09:55:32 · 102 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1073 Scientific Notation (20分)
1.题目Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that th...原创 2020-04-17 09:48:38 · 133 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1079 Total Sales of Supply Chain (25分) (DFS+map存储product)
1.题目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...原创 2020-04-16 21:09:46 · 216 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1078 Hashing (25分) (平方探测)
1.题目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 beH(key)=ke...原创 2020-04-16 20:36:03 · 131 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1077 Kuchiguse (20分) (string反转)
1.题目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 c...原创 2020-04-16 19:53:43 · 144 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1083 List Grades (25分) (思路转换)
1.题目Given a list ofNstudent 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 g...原创 2020-04-16 18:34:55 · 151 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1081 Rational Sum (20分) (注意精度问题!)
1.题目GivenNrational numbers in the formnumerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positi...原创 2020-04-16 15:54:58 · 144 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1087 All Roads Lead to Rome (30分)(Dijkstra+超详细步骤注释)
1.题目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:...原创 2020-04-16 10:43:21 · 246 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1086 Tree Traversals Again (25分) (寻找先序遍历(+建树+)后序遍历)
1.题目An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, th...原创 2020-04-15 18:53:23 · 159 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1085 Perfect Sequence (25分)
1.题目Given a sequence of positive integers and another positive integerp. The sequence is said to be aperfect sequenceifM≤m×pwhereMandmare the maximum and minimum numbers in the sequence, re...原创 2020-04-15 10:29:26 · 120 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1084 Broken Keyboard (20分)
1.题目On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are suppo...原创 2020-04-15 10:26:14 · 154 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1090 Highest Price in Supply Chain (25分) (DFS⭐⭐⭐)
1.题目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...原创 2020-04-15 09:43:31 · 135 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1089 Insert or Merge (25分)
1.题目According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input...原创 2020-04-15 09:04:28 · 96 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1088 Rational Arithmetic (20分)
1.题目For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one ...原创 2020-04-15 08:59:02 · 112 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1094 The Largest Generation (25分) (BFS改进)
1.题目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....原创 2020-04-11 20:14:35 · 137 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1093 Count PAT's (25分)
1.题目The stringAPPAPTcontains twoPAT'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....原创 2020-04-11 17:02:06 · 132 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1092 To Buy or Not to Buy (20分)
1.题目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 on...原创 2020-04-11 16:59:06 · 102 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1099 Build A Binary Search Tree (30分) (二叉搜索树)
1.题目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 ri...原创 2020-04-11 16:55:45 · 106 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1098 Insertion or Heap Sort (25分) (堆排序)
1.题目According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input...原创 2020-04-11 16:23:52 · 106 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1097 Deduplication on a Linked List (25分) (静态链表+测试实例)
1.题目Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK, only the first node of which the valu...原创 2020-04-10 20:42:04 · 111 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1096 Consecutive Factors (20分)
1.题目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 ...原创 2020-04-10 14:36:52 · 111 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1102 Invert a Binary Tree (25分) (层序遍历)
1.题目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 t...原创 2020-04-09 22:18:19 · 130 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1101 Quick Sort (25分)
1.题目There is a classical process namedpartitionin 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 ...原创 2020-04-09 21:08:41 · 168 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1100 Mars Numbers (20分)
1.题目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 ...原创 2020-04-09 21:00:57 · 144 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1107 Social Clusters (30分) (并查集)
1.题目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 people who have some o...原创 2020-04-09 20:54:26 · 136 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1105 Spiral Matrix (25分)
1.题目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-left corner, then m...原创 2020-04-08 16:34:42 · 94 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1104 Sum of Number Segments (20分)
1.题目Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0....原创 2020-04-08 16:32:16 · 110 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1111 Online Map (30分) (两次迪杰斯特拉混合)
1.题目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. I...原创 2020-04-08 16:27:51 · 123 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1110 Complete Binary Tree (25分) (完全二叉树的判断+分享致命婴幼儿错误)
1.题目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 gives a positive integerN(≤...原创 2020-04-07 19:07:34 · 194 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1109 Group Photo (25分)
1.题目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 down to the neares...原创 2020-04-07 16:59:38 · 119 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1108 Finding Average (20分)
1.题目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 legal. Alegalinput is ...原创 2020-04-07 16:51:24 · 123 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1114 Family Property (25分) (并查集+标记)
1.题目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 ...原创 2020-04-07 16:49:28 · 211 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1115 Counting Nodes in a BST (30分) (不用BFS、DFS、不用遍历直接建树标记完事)
1.题目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 ...原创 2020-04-07 14:52:04 · 146 阅读 · 0 评论