
PAT
pat算法笔记
CSHran
这个作者很懒,什么都没留下…
展开
-
PAT A1030 Travel Plan (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805464397627392题目描述A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. ...原创 2020-04-25 16:39:25 · 234 阅读 · 0 评论 -
PAT A1003 Emergency (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805523835109376题目描述As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several...原创 2020-04-23 20:27:56 · 217 阅读 · 0 评论 -
PAT A1076 Forwards on Weibo (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805392092020736题目描述Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many...原创 2020-04-22 13:37:03 · 264 阅读 · 0 评论 -
PAT A1034 Head of a Gang (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805456881434624题目描述One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call betw...原创 2020-04-22 12:17:38 · 235 阅读 · 0 评论 -
1098 Insertion or Heap Sort (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805368847187968题目描述According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sort...原创 2020-04-20 16:10:16 · 3020 阅读 · 0 评论 -
PAT A1107 Social Clusters (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805361586847744题目描述When register on a social network, you are always asked to specify your hobbies in order to find some potential ...原创 2020-04-19 19:06:26 · 201 阅读 · 0 评论 -
PAT A1066 Root of AVL Tree (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805404939173888题目描述An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any...原创 2020-04-19 17:05:53 · 243 阅读 · 0 评论 -
PAT A1091 Acute Stroke (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805375457411072题目描述One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of ima...原创 2020-04-12 18:58:49 · 183 阅读 · 0 评论 -
PAT A1103 Integer Factorization (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805364711604224题目描述The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers....原创 2020-04-11 18:51:39 · 232 阅读 · 0 评论 -
PAT A1099 Build A Binary Search Tree (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805367987355648题目描述A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left ...原创 2020-04-11 10:16:56 · 298 阅读 · 0 评论 -
PAT A1064 Complete Binary Search Tree (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805407749357568题目描述A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left ...原创 2020-04-10 23:31:32 · 249 阅读 · 0 评论 -
PAT A1043 Is It a Binary Search Tree (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805440976633856题目描述A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left ...原创 2020-04-10 23:15:33 · 180 阅读 · 0 评论 -
PAT A1053 Path of Equal Weight (30分)
题目链接:题目描述Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti . The weight of a path from R to L is defined to be the sum of the weights of all the nodes alon...原创 2020-04-10 22:35:58 · 218 阅读 · 0 评论 -
PAT A1004 Counting Leaves (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805521431773184题目描述A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have n...原创 2020-04-10 21:49:20 · 165 阅读 · 0 评论 -
PAT A1106 Lowest Price in Supply Chain (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464题目描述A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in movi...原创 2020-04-09 23:09:36 · 187 阅读 · 0 评论 -
PAT A1094 The Largest Generation (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805372601090048题目描述A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the s...原创 2020-04-09 22:58:44 · 160 阅读 · 0 评论 -
PAT A1079 Total Sales of Supply Chain (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805388447170560题目描述A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in movi...原创 2020-04-09 22:42:08 · 210 阅读 · 0 评论 -
PAT A1090 Highest Price in Supply Chain (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805376476626944题目描述A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in movi...原创 2020-04-09 22:24:14 · 144 阅读 · 0 评论 -
PAT A1102 Invert a Binary Tree (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805365537882112题目描述The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), b...原创 2020-04-09 22:01:05 · 150 阅读 · 0 评论 -
PAT A1086 Tree Traversals Again (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805380754817024题目描述可以以非递归方式使用堆栈来实现有序二叉树遍历。例如,假设遍历6节点的二叉树(键的编号从1到6),则堆栈操作为:push(1); push(2); push(3); pop(); pop(); push(4); pop(); ...原创 2020-04-09 19:01:22 · 162 阅读 · 0 评论 -
PAT A1097 Deduplication on a Linked List (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805369774129152题目描述Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute va...原创 2020-04-05 21:06:01 · 158 阅读 · 0 评论 -
PAT A1074 Reversing Linked List (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805394512134144题目描述Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. F...原创 2020-04-03 21:14:32 · 147 阅读 · 0 评论 -
PAT B1025 反转链表 (25分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805296180871168题目描述给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转。例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 3→2→1→6→5→4;如果 K 为 4,则输出应该为 4→3→2→1→5→...原创 2020-04-03 21:12:01 · 199 阅读 · 0 评论 -
PAT A1056 Mice and Rice (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805419468242944题目描述Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to contro...原创 2020-04-03 17:20:19 · 166 阅读 · 0 评论 -
PAT A1051 Pop Sequence (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805427332562944题目描述Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. Y...原创 2020-04-03 16:11:57 · 248 阅读 · 0 评论 -
PAT A1022 Digital Library (30分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805480801550336题目描述A Digital Library contains millions of books, stored according to their titles, authors, key words of their abst...原创 2020-04-03 14:54:15 · 223 阅读 · 0 评论 -
PAT A1071 Speech Patterns (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805398257647616题目描述People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while...原创 2020-04-02 19:31:53 · 197 阅读 · 0 评论 -
PAT A1054 The Dominant Color (20分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768题目描述Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information f...原创 2020-04-02 18:24:01 · 153 阅读 · 0 评论 -
PAT A1100 Mars Numbers (20分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805367156883456题目描述People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on ...原创 2020-04-01 17:37:05 · 136 阅读 · 0 评论 -
PAT A1063 Set Similarity (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805409175420928题目描述Given two sets of integers, the similarity of the sets is defined to be Nc /Nt ×100%, where Nc is the ...原创 2020-04-01 16:16:55 · 182 阅读 · 0 评论 -
PAT A1047 Student List for Course (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805433955368960题目描述Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each...原创 2020-04-01 15:15:23 · 155 阅读 · 0 评论 -
PAT A1039 Course List for Student (25分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805447855292416题目描述Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the co...原创 2020-04-01 14:27:04 · 201 阅读 · 0 评论 -
PAT B1074 宇宙无敌加法器 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805263297527808题目描述地球人习惯使用十进制数,并且默认一个数字的每一位都是十进制的。而在 PAT 星人开挂的世界里,每个数字的每一位都是不同进制的,这种神奇的数字称为“PAT数”。每个 PAT 星人都必须熟记各位数字的进制表,例如“……0527”...原创 2020-03-31 23:25:43 · 196 阅读 · 0 评论 -
PAT B1094 谷歌的招聘 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1071785997033074688题目描述2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘。内容超级简单,就是一个以 .com 结尾的网址,而前面的网址是一个 10 位素数,这个素数是自然常数 e 中最早出现的 10 位...原创 2020-03-31 22:46:45 · 309 阅读 · 0 评论 -
PAT B1092 最好吃的月饼 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1071785779399028736题目描述月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出全国各地各种月饼的销量,要求你从中找出销量冠军,认定为最好...原创 2020-03-31 22:09:55 · 277 阅读 · 0 评论 -
PAT B1090 危险品装箱 (25分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1038429484026175488题目描述集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里。比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸。本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里。...原创 2020-03-31 21:58:25 · 327 阅读 · 0 评论 -
PAT B1091 N-自守数 (15分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1071785664454127616题目描述如果某个数 K 的平方乘以 N 以后,结果的末尾几位数等于 K,那么就称这个数为“N-自守数”。例如 3×922 =25392,而 25392 的末尾两位正好是 92,所以 92 是一个 3-自守数。本题就请你编写...原创 2020-03-31 21:21:50 · 196 阅读 · 0 评论 -
PAT B1089 狼人杀-简单版 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1038429385296453632题目描述以下文字摘自《灵机一动·好玩的数学》:“狼人杀”游戏分为狼人、好人两大阵营。在一局“狼人杀”游戏中,1 号玩家说:“2 号是狼人”,2 号玩家说:“3 号是好人”,3 号玩家说:“4 号是狼人”,4 号玩家说:“5 号是好...原创 2020-03-31 20:51:35 · 310 阅读 · 0 评论 -
PAT B1088 三人行 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1038429286185074688题目描述子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。”本题给定甲、乙、丙三个人的能力值关系为:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍...原创 2020-03-31 19:18:31 · 162 阅读 · 0 评论 -
PAT B1087 有多少不同的值 (20分)
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/1038429191091781632题目描述当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。)输入输入给出一个正整数 N(2≤...原创 2020-03-31 18:48:58 · 181 阅读 · 0 评论