PAT(Advanced Level)
文章平均质量分 61
R_1220
接下来是雪花,圣诞,新年,和更好的我们
展开
-
1004 Counting Leaves
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 distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One原创 2023-01-03 23:38:36 · 107 阅读 · 1 评论 -
1013 Battle Over Cities
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-11-21 14:51:51 · 344 阅读 · 0 评论 -
1098 Insertion or Heap Sort(堆排序解释)(PAT甲级)
堆排序是对选择排序的改进,利用数据结构来排序。1.编写向下过滤函数percDown2.建立最大堆3.每次将堆顶(即最大值)与最后一个元素交换,然后“抛弃”最后一个元素,知道将最大堆转换成升序数组我们根据父节点和子节点的大小关系来判断是否需要交换父子结点,使得满足最大堆序。由于最大堆一定是完全二叉树,所以我们可以用数组存储数据。由于需要满足每个父节点都比起子节点大,自然的想到,从最后一个父节点开始做判断。那么传入的第一个父节点的下标就是(len / 2 - 1) 其中len是数组长度。 如上图所示,我们找到原创 2022-06-23 16:33:59 · 528 阅读 · 0 评论 -
1001 A+B Format (20 分)
Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Specification: Each input file contains one test case. Each case contains a pair ...原创 2022-03-17 22:13:17 · 56 阅读 · 0 评论