![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT甲级
文章平均质量分 92
@Star
这个作者很懒,什么都没留下…
展开
-
2019年秋PAT总结
总览判断,偶尔看看题榜,决定做题顺序。一定要认真审题,注意细节,比如no的时候输出什么……思路清晰再下笔。很烂的结果,往往隐藏着最正确的答案。王瑜最棒!7-1 Forever 未作答 得分: 0 / 20"Forever number" is a positive integer A with K digits, satisfying the followi...原创 2019-12-07 10:39:44 · 152 阅读 · 0 评论 -
1042 Shuffling Machine (20 分)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamble...原创 2019-12-01 10:19:33 · 98 阅读 · 0 评论 -
1017 Queueing at Bank (25 分)
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow l...原创 2019-11-30 17:03:01 · 70 阅读 · 0 评论 -
1014 Waiting in Line (30 分)
Suppose a bank has NNN windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The sp...原创 2019-11-30 12:16:06 · 50 阅读 · 0 评论 -
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 ...原创 2019-11-27 14:13:31 · 60 阅读 · 0 评论 -
1044 Shopping in Mars (25 分)
题意:求一串的数字中连续的一段,使得这个连续的段内数字的和恰好等于所期望的值m。如果不能找到恰好等于,就找让自己付出最少的价格(总和必须大于等于所给值)的那段区间。求所有可能的结果。分析:简单模拟有两个超时。后来想到因为sum数组是递增的,所以改用二分法查找~子函数的作用是二分查找,修改tempans和j的值~一开始接收输入的时候可以直接保存它的sum函数,即sum[i]表示1~i的所有数字的...原创 2019-11-27 13:39:04 · 66 阅读 · 0 评论 -
1010 Radix (25 分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive int...原创 2019-11-25 21:19:31 · 53 阅读 · 0 评论 -
1095 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 the cars crossing the gate. Now with all the information available, you ...原创 2019-11-25 09:04:09 · 65 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree (30 分)
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 more than one, rebalancing i...原创 2019-11-24 21:18:24 · 68 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 分) (Z字形层序输出二叉树)
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. And it is a simple stan...原创 2019-11-24 17:59:04 · 78 阅读 · 0 评论 -
1135 Is It A Red-Black Tree (30 分)()
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black. (2) The root is black. (3) Ever...原创 2019-11-23 20:58:59 · 67 阅读 · 0 评论 -
1139 First Contact(30 分)
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly ...原创 2019-11-23 12:23:49 · 412 阅读 · 0 评论 -
1151 LCA in a Binary Tree (30 分)&1147 Heaps (30 分) &1143 Lowest Common Ancestor (30 分)&(二叉树、堆的判断)
The 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 supposed to find their LCA.I...原创 2019-11-23 07:38:49 · 56 阅读 · 0 评论 -
1056 Mice and Rice (25 分)(queue的用法)
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 ric...原创 2019-11-22 16:40:31 · 57 阅读 · 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 } i...原创 2019-11-21 11:24:18 · 64 阅读 · 0 评论 -
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%TSi...原创 2019-11-21 10:34:24 · 83 阅读 · 0 评论 -
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 gives a positive integer N (≤20) w...原创 2019-11-20 09:36:22 · 151 阅读 · 0 评论 -
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 supposed to tell if a given cycle...原创 2019-11-20 07:32:09 · 458 阅读 · 0 评论 -
1134 Vertex Cover (25 分)(无向图计算——最小顶点覆盖)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if ...原创 2019-11-18 21:44:28 · 273 阅读 · 0 评论 -
1142 Maximal Clique (25 分)(部分完全图/最大部分完全图)
A 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 extended by including one more ad...原创 2019-11-18 19:12:05 · 90 阅读 · 0 评论 -
1146 Topological 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 supposed to write a program to test...原创 2019-11-18 13:16:34 · 76 阅读 · 0 评论 -
1150 Travelling 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 possible route that visits each city and ret...原创 2019-11-18 11:06:08 · 40 阅读 · 0 评论 -
1003 Emergency (25 分)
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the ...原创 2019-08-26 09:07:30 · 40 阅读 · 0 评论 -
1051 Pop Sequence (25 分) (模拟栈)
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of ...原创 2019-04-25 19:21:06 · 45 阅读 · 0 评论 -
1047 Student List for Course && 1039 Course List for Student (25 分)(变长的vector、hash,or map+set)
1047:printf("%s\n",vs[i][j].c_str());//不用%s会超时map+set is okZhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are s...原创 2019-08-22 15:13:35 · 54 阅读 · 0 评论 -
1055 The World‘s Richest (25 分) (排序)
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peop...原创 2019-04-21 19:34:24 · 83 阅读 · 0 评论 -
1036 Boys vs Girls (25 分) (查找元素)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one ...原创 2019-04-25 22:06:47 · 42 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 分)(查找)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, yo...原创 2019-05-07 13:53:15 · 36 阅读 · 0 评论 -
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 subseque...原创 2019-05-07 15:38:54 · 44 阅读 · 0 评论 -
1009 Product of Polynomials (25 分) (多项式乘法)
This time, you are supposed to find A×BA\times BA×B where AAA and BBB are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line con...原创 2019-05-07 16:39:19 · 50 阅读 · 0 评论 -
PAT树专题
1.已知后序和中序,求层序输出——利用两序建树,后bfs输出树上结点值例题 PAT甲 1020 Tree Traversals (25 分)https://pintia.cn/problem-sets/994805342720868352/problems/994805485033603072int pos[35],in[35];node* root=build(0,n-1,0,n...原创 2019-11-18 20:38:27 · 173 阅读 · 0 评论 -
1057 Stack (30 分) (线段树找第N小的数)
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 top position) and P...原创 2019-08-20 22:14:12 · 51 阅读 · 0 评论 -
1066 Root 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 more than one, rebalancing i...原创 2019-08-25 10:46:58 · 50 阅读 · 0 评论 -
1098 Insertion or Heap Sort (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...原创 2019-11-21 19:00:14 · 73 阅读 · 0 评论 -
1103 Integer Factorization (30 分)
The K−PK-PK−P factorization of a positive integer NNN is to write NNN as the sum of the PPP-th power of KKK positive integers. You are supposed to write a program to find the K−PK-PK−P factorizati...原创 2019-08-21 16:54:48 · 130 阅读 · 0 评论 -
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 MRI slice, your job is ...原创 2019-08-21 19:06:20 · 62 阅读 · 0 评论 -
1022 Digital Library (30 分) (map,set,字符串处理)
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 ...原创 2019-08-22 12:05:56 · 50 阅读 · 0 评论 -
PAT甲级真题目录(按题型整理)
最短路径1003. Emergency (25)-PAT甲级真题(Dijkstra算法)1018. Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS)1030. Travel Plan (30)-PAT甲级真题(Dijkstra + DFS,输出路径,边权)1087. All Roads Lead to Rome (30)-PAT甲级真题-Di...原创 2019-10-07 17:08:49 · 214 阅读 · 0 评论 -
PAT——最短路径
1018 Public Bike Management (30 分) (Dijkstra+dfs)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike a...原创 2019-08-27 10:36:04 · 251 阅读 · 0 评论 -
PAT——图专题
1013 Battle Over Cities (25 分)题目:n个城市(1到n),m条路,k个询问的城市,问当某城被攻陷时,若使其它各城连通,至少要修几条路。思路:vis[i]标识该城是否访问,若被攻陷则置为1,遍历1到n,若不为1则dfs——标记,访问与其联通的点,计算连通分量,最少需要修的道路的数量为连通分量-1注意:cin、cout会超时用scanf、printf io...原创 2019-09-10 17:21:36 · 85 阅读 · 0 评论