
PAT
浙江大学计算机程序设计能力考试(Programming Ability Test,简称PAT)。本人关于PAT甲级的刷题目录和题解。
love music.
中山大学计算机博士在读,曾就职于腾讯等公司,目前从事AI多模态大模型研究。
展开
-
PAT甲级 1111 Online Map (30 分)dijkstra + dfs
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...原创 2019-01-02 19:47:01 · 345 阅读 · 0 评论 -
PAT甲级 1122 Hamiltonian Cycle (25 分)图论
1122 Hamiltonian 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 sup...原创 2018-12-29 19:49:47 · 155 阅读 · 0 评论 -
PAT甲级 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...原创 2018-12-29 19:44:05 · 312 阅读 · 0 评论 -
PAT甲级 1121 Damn Single (25 分)set
1121 Damn 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 ...原创 2018-12-16 17:41:43 · 180 阅读 · 0 评论 -
PAT 甲级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...原创 2018-12-09 22:05:00 · 231 阅读 · 0 评论 -
PAT甲级 1117 Eddington Number (25 分)逻辑题
1117 Eddington 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 in...原创 2018-12-08 11:54:06 · 382 阅读 · 0 评论 -
PAT甲级 1116 Come on! Let's C (20 分)hash散列
1116 Come 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...原创 2018-12-07 20:52:47 · 179 阅读 · 0 评论 -
PAT甲级 1120 Friend Numbers (20 分)水题
1120 Friend 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+...原创 2018-12-07 20:47:08 · 182 阅读 · 0 评论 -
PAT甲级 1115 Counting Nodes in a BST (30 分)bst
1115 Counting 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 le...原创 2018-11-29 21:14:55 · 194 阅读 · 0 评论 -
PAT甲级 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 n1and n2 numbers, respectively. Let S...原创 2018-11-29 16:49:10 · 162 阅读 · 0 评论 -
PAT甲级 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 fo...原创 2018-11-29 15:35:49 · 215 阅读 · 0 评论 -
PAT甲级 1110 Complete Binary Tree (25 分)完全二叉树、dfs
1110 Complete 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 g...原创 2018-11-29 10:32:23 · 203 阅读 · 0 评论 -
PAT甲级 1108 Finding Average (20 分)字符串处理
1108 Finding Average (20 分)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be l...原创 2018-11-25 21:27:06 · 243 阅读 · 0 评论 -
PAT甲级 1106 Lowest Price in Supply Chain (25 分)dfs
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.Start...原创 2018-11-24 17:35:31 · 198 阅读 · 0 评论 -
PAT甲级 1105 Spiral Matrix (25 分)模拟
1105 Spiral Matrix (25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the uppe...原创 2018-11-24 11:51:14 · 213 阅读 · 0 评论 -
PAT甲级 1102 Invert a Binary Tree (25 分)树的遍历(bfs+dfs)
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...原创 2018-11-20 18:20:59 · 183 阅读 · 0 评论 -
PAT甲级 1104 Sum of Number Segments (20 分)数学问题
1104 Sum of Number Segments (20 分)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 segme...原创 2018-11-20 17:11:46 · 179 阅读 · 0 评论 -
PAT甲级 1100 Mars Numbers (20 分)map、string
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 Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep...原创 2018-11-20 16:30:59 · 205 阅读 · 0 评论 -
PAT甲级 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 thre...原创 2018-11-18 21:15:06 · 183 阅读 · 0 评论 -
PAT甲级 1095 Cars on Campus (30 分)排序
参考链接:https://www.liuchuo.net/archives/29511095 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 t...原创 2018-11-18 16:45:48 · 330 阅读 · 0 评论 -
PAT甲级 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 p...原创 2018-11-17 12:07:38 · 234 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30 分)dfs、bfs、bst
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...原创 2018-11-12 11:52:01 · 282 阅读 · 0 评论 -
PAT甲级 1097 Deduplication on a Linked List (25 分)链表
1097 Deduplication on a Linked List (25 分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K,...原创 2018-11-09 22:41:32 · 206 阅读 · 0 评论 -
PAT甲级 1094 The Largest Generation (25 分)BFS,树的宽度
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 ...原创 2018-11-09 22:36:59 · 162 阅读 · 0 评论 -
1091 Acute Stroke (30 分)BFS
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 M...原创 2018-11-08 16:42:08 · 541 阅读 · 0 评论 -
PAT甲级 1093 Count PAT's (25 分)逻辑题
参考链接:https://www.liuchuo.net/archives/18961093 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 se...原创 2018-11-07 20:10:34 · 342 阅读 · 0 评论 -
PAT甲级 1092 To Buy or Not to Buy (20 分)hash散列
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 th...原创 2018-11-05 20:13:29 · 159 阅读 · 0 评论 -
PAT甲级 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...原创 2018-11-05 15:26:58 · 239 阅读 · 0 评论 -
PAT甲级 1090 Highest Price in Supply Chain (25 分)dfs (树的遍历)
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.Star...原创 2018-11-04 15:05:31 · 155 阅读 · 0 评论 -
PAT甲级 1088 Rational Arithmetic (20 分)数学运算
1088 Rational Arithmetic (20 分)For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Ea...原创 2018-11-03 11:45:28 · 149 阅读 · 0 评论 -
PATj甲级 1087 All Roads Lead to Rome (30 分)dijkstra + dfs
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 hap...原创 2018-10-25 22:19:42 · 212 阅读 · 0 评论 -
PAT甲级 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 p...原创 2018-10-22 22:31:05 · 200 阅读 · 0 评论 -
PAT甲级 1077 Kuchiguse (20 分)字符串处理
1077 Kuchiguse (20 分)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 ...原创 2018-10-21 21:39:35 · 343 阅读 · 0 评论 -
PAT甲级 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 ...原创 2018-10-21 21:01:52 · 437 阅读 · 1 评论 -
1084 Broken Keyboard (20 分)has散列
1084 Broken Keyboard (20 分)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 st...原创 2018-10-21 16:15:50 · 286 阅读 · 0 评论 -
PAT甲级 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 rec...原创 2018-10-21 12:20:23 · 238 阅读 · 0 评论 -
1082 Read Number in Chinese (25 分)字符串处理
1082 Read Number in Chinese (25 分)Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 ...原创 2018-10-21 12:11:18 · 1025 阅读 · 0 评论 -
PAT 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 ...原创 2018-10-18 10:33:42 · 431 阅读 · 0 评论 -
PAT甲级 1079 Total Sales of Supply Chain (25 分)DFS
参考链接:https://www.cnblogs.com/grglym/p/7922417.html1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in...原创 2018-10-16 21:54:46 · 239 阅读 · 0 评论 -
PAT甲级 1076 Forwards on Weibo (30 分)BFS 图的遍历
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 wi...原创 2018-10-08 22:04:44 · 225 阅读 · 0 评论