![](https://img-blog.csdnimg.cn/20190927151132530.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT甲级刷题之路
文章平均质量分 82
收集本人刷PAT甲级题目时候的一些思路及总结
神笔码农.
重拾写作,分享自己所学,希望对大家有所帮助
展开
-
PAT甲级刷题之路--题目索引+知识点分析(正在进行)
PAT甲级题目汇总+知识点分析,持续更新中原创 2022-03-01 16:06:52 · 552 阅读 · 0 评论 -
1064 Complete Binary Search Tree(30分)-PAT甲级
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 right subtree of a node contains only nodes with keys great原创 2022-05-31 16:50:30 · 142 阅读 · 0 评论 -
1038 Recover the Smallest Number(30分)-PAT甲级
Given a collection(集合) of number segments(片段), you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 with respect to diffe原创 2022-05-31 16:33:47 · 107 阅读 · 0 评论 -
1045 Favorite Color Stripe(30分)-PAT甲级
Eva is trying to make her own color stripe(条纹) out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.It is原创 2022-05-28 11:09:11 · 162 阅读 · 0 评论 -
1065 A+B and C (64bit)-PAT甲级
Given three integersA,BandCin (−263,263), you are supposed to tell whetherA+B>C.Input Specification:The first line of the input gives the positive number of test cases,T(≤10). ThenTtest cases follow, each consists of a single line containi...原创 2022-05-15 22:06:10 · 243 阅读 · 0 评论 -
1066 Root of AVL Tree-PAT甲级
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 is done to restore this property. Figures 1-4 illustrate t原创 2022-05-14 22:07:02 · 150 阅读 · 0 评论 -
1055 The World‘s Richest (25 分)-PAT甲级
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 people in a certain range of ages. That is, given the net wor原创 2022-04-08 20:09:25 · 476 阅读 · 0 评论 -
1053 Path of Equal Weight (30 分)-PAT甲级
Given a non-empty tree with rootR, and with weightWiassigned to each tree nodeTi. Theweight of a path fromRtoLis defined to be the sum of the weights of all the nodes along the path fromRto any leaf nodeL.Now given any weighted tree, you ar...原创 2022-04-08 19:10:21 · 263 阅读 · 0 评论 -
1048 Find Coins (25 分)-PAT甲级
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for eac原创 2022-04-06 23:00:32 · 448 阅读 · 0 评论 -
1046 Shortest Distance (20 分)-PAT甲级
The task is really simple: givenNexits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each case, the first line contain..原创 2022-04-06 22:40:38 · 204 阅读 · 0 评论 -
1047 Student List for Course (25 分)-PAT甲级
Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:Each input file contains one test case. F原创 2022-04-06 16:39:29 · 1205 阅读 · 0 评论 -
1029 Median (25 分)-PAT甲级
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 15. The median of two sequences is defined to be the me原创 2022-04-06 15:50:57 · 220 阅读 · 0 评论 -
1057 Stack (30 分)-PAT甲级
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 Pop (deleting the top element). Now you are supposed to im原创 2022-04-05 21:52:26 · 314 阅读 · 1 评论 -
1044 Shopping in Mars (25 分)-PAT甲级
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position for only once and some of the diamonds are taken off the原创 2022-03-24 22:20:31 · 621 阅读 · 0 评论 -
1051 Pop Sequence (25 分)-PAT甲级
Given a stack which can keepMnumbers at most(至多). PushNnumbers in the order of 1, 2, 3, ...,Nand pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, ifMis 5 andNis 7, we can ...原创 2022-03-22 22:10:56 · 207 阅读 · 0 评论 -
1058 A+B in Hogwarts (20 分)-PAT甲级
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough." Your job is to write a program原创 2022-03-20 16:37:56 · 360 阅读 · 0 评论 -
1054 The Dominant Color (20 分)-PAT甲级
Behind the scenes(场景) in the computer's memory(内存), color is always talked about as a series of 24 bits of information for each pixel(像素). In an image, the color with the largest proportional area(比例面积) is called the dominant(占优势的、占主导地位的) color. Astrictly.原创 2022-03-20 16:12:45 · 369 阅读 · 0 评论 -
1052 Linked List Sorting (25 分)-PAT甲级
A linked list consists of a series of structures, which are not necessarily adjacent in memory(在内存中相邻). We assume that each structure contains an integerkeyand aNextpointer to the next structure. Now given a linked list, you are supposed to sort the st...原创 2022-03-20 11:22:35 · 1040 阅读 · 0 评论 -
1040 Longest Symmetric String (25 分)-PAT甲级
Given a string, you are supposed to output the length of the longest symmetric(对称的) sub-string. For example, givenIs PAT&TAP symmetric?, the longest symmetric sub-string iss PAT&TAP s, hence you must output11.Input Specification:Each input f...原创 2022-03-18 11:42:09 · 254 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25 分)-PAT甲级
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 right subtree of a node contains only nodes with key原创 2022-03-22 17:11:27 · 1037 阅读 · 0 评论 -
1034 Head of a Gang (30 分)-PAT甲级
One way that the police finds the head of a gang(帮派) is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight(权重) of a relation is defined to be the total time length of all the phone calls made...原创 2022-03-15 11:52:03 · 386 阅读 · 0 评论 -
1022 Digital Library (30 分)-PAT甲级
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 as its ID. Given any query from a reader, you are suppose原创 2022-03-14 21:44:13 · 433 阅读 · 0 评论 -
1030 Travel Plan (30 分)-PAT甲级
A traveler's map gives the distances between cities along the highways(高速公路), together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path(最短路径) between his/her starting city and the destina原创 2022-03-12 16:36:46 · 170 阅读 · 0 评论 -
1037 Magic Coupon (25 分)-PAT甲级
The magic shop in Mars is offering some magic coupons(优惠券). Each coupon has an integerNprinted on it, meaning that when you use this coupon with a product, you may getNtimes the value of that product back(你可以拿回该产品价值的N倍)! What is more(而且), the shop also...原创 2022-03-12 15:25:38 · 204 阅读 · 0 评论 -
1039 Course List for Student (25 分)-PAT甲级
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query(查询).Input Specification:Each input file原创 2022-03-12 09:23:44 · 97 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)-PAT甲级
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 we need to repair any other highways to keep the rest of the c原创 2022-03-09 22:05:31 · 212 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)-PAT甲级
Given a sequence(序列,数列) ofKintegers {N1,N2, ...,NK}. A continuous(连续的) subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For exampl...原创 2022-03-09 16:32:35 · 213 阅读 · 0 评论 -
1003 Emergency (25 分)-PAT甲级
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 length of each road between any pair原创 2022-03-08 22:38:22 · 142 阅读 · 0 评论 -
1021 Deepest Root (25 分)-PAT甲级
A graph(图表) which is connected and acyclic(非循环的,非周期的) can be considered a tree. The height of the tree depends on the selected(选择的) root. Now you are supposed to find the root that results in a highest tree. Such a root is calledthe deepest root.Input S.原创 2022-03-06 17:13:01 · 583 阅读 · 0 评论 -
1042 Shuffling Machine (20 分)-PAT甲级
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 gamblers(与赌徒合作) by performing inadequate shuffles原创 2022-03-01 17:11:03 · 104 阅读 · 0 评论 -
1050 String Subtraction (20 分)-PAT甲级
Given two stringsS1andS2,S=S1−S2is defined to be the remaining string after taking all the characters inS2fromS1. Your task is simply to calculateS1−S2for any given strings. However, it might not be that simple to do itfast.Input Speci...原创 2022-02-28 23:03:20 · 165 阅读 · 0 评论 -
1041 Be Unique (20 分)-PAT甲级
Being unique is so important to people on Mars that even(甚至) their lottery(彩票) is designed in a unique way. The rule of winning is simple(简单的): one bets on a number chosen from [1,104]. The first one who bets on a unique number wins. For example, if there原创 2022-02-28 21:05:02 · 193 阅读 · 0 评论 -
1036 Boys vs Girls (25 分)-PAT甲级
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 test case. Each case contains a positive integerN, follo.原创 2022-02-27 23:03:40 · 368 阅读 · 0 评论 -
1035 Password (20 分)-PAT甲级
To prepare for PAT, the judge sometimes has to generate random(随机的) passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish1(one) froml(Lin lowercase), or0(zero) fromO(oin uppercase(大...原创 2022-02-27 22:43:10 · 139 阅读 · 0 评论 -
1032 Sharing (25 分)-PAT甲级
To store English words, one method(方法) is to use linked lists(链表)and store a word letter by letter. To save some space, we may let the words share the same sublist(子列表) if they share the same suffix(后缀). For example,loadingandbeingare stored as showed...原创 2022-02-27 12:39:24 · 299 阅读 · 0 评论 -
1004 Counting Leaves (30 分)-PAT甲级
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 starts with a line containing0<N<100, the.原创 2022-03-07 12:37:25 · 220 阅读 · 0 评论 -
1031 Hello World for U (20 分)-PAT甲级
Given any string ofN(≥5) characters, you are asked to form the characters into the shape ofU. For example,helloworldcan be printed as:h de ll rlowoThat is, the characters must be printed in the original order, starting top-down from the le...原创 2022-02-27 10:45:17 · 129 阅读 · 0 评论 -
1028 List Sorting (25 分)-PAT甲级
Excel can sort records according to any column(列). Now you are supposed to imitate(模仿) this function.Input Specification:Each input file contains one test case. For each case, the first line contains two integersN(≤105) andC, whereNis the number o...原创 2022-02-24 20:44:39 · 163 阅读 · 0 评论 -
1027 Colors in Mars (20 分)-PAT甲级
People in Mars represent(展示) the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are forRed, the middle 2 digits forGreen, and the last 2 digits forBlue. The o...原创 2022-02-24 15:49:34 · 242 阅读 · 0 评论 -
1023 Have Fun with Numbers (20 分)-PAT甲级
Notice that the number 123456789 is a 9-digit number consisting(由……组成) exactly the numbers from 1 to 9, with no duplication(重复). Double(两倍) it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9,原创 2022-02-24 15:09:29 · 113 阅读 · 0 评论