
PAT甲级
文章平均质量分 57
kyln1039
这个作者很懒,什么都没留下…
展开
-
PAT专题训练——数字题
PAT专题训练——数字题一.A+B系列1001100210581065二.数的表达系列1005三.进制相关1010101510191027四.逐位处理102310241060翻转数1069一.A+B系列1001该题的重点是:A和B是数字,将A+B的结果用标准形式表现出Sample Input:-1000000 9Sample Output:-999,991解决方法:将结果的每位数从后往前保存在数组中,再从前往后输出,每三位再输出一个,题目通道PAT A1011002该题的A和B是多项式原创 2021-04-28 18:22:50 · 224 阅读 · 0 评论 -
PAT专题训练——数列
PAT专题训练——数列A1007 求和最大子序列A1029 求两个有序序列的中位数A1007 求和最大子序列A1029 求两个有序序列的中位数原创 2021-04-28 18:22:34 · 125 阅读 · 0 评论 -
PAT A1007 Maximum Subsequence Sum (25分)
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 subsequence whi原创 2020-09-03 21:19:15 · 135 阅读 · 0 评论 -
PAT专题训练——图
PAT专题训练——图图有关的题图的建立1.邻接矩阵题型1.最短路径Dijkstra2.最小路径Dijkstra+结点权重图有关的题1003、1013、1018、1021、1030、1046、1072、1076、1087、1111、1122、1124、1126、1131、1134、1139、1142、1146、1150、1154图的建立1.邻接矩阵typedef struct { int Vex[MaxVertexNum];//结点信息 int Edge[MaxVertexNum][MaxVer原创 2020-09-03 19:34:27 · 349 阅读 · 0 评论 -
PAT A1150 Travelling Salesman Problem (25分)
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 retur原创 2020-09-02 17:10:32 · 166 阅读 · 0 评论 -
PAT A1018 Public Bike Management (30分)
1018 Public Bike Management 30分原题大体题意思路代码运行结果原题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 at any station and return it to any other stations in the city.T原创 2020-09-03 16:33:09 · 141 阅读 · 0 评论 -
PAT A1076 Forwards on Weibo (30分)
PAT A1076 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 with followers relations. When a user ma原创 2020-09-02 14:37:07 · 120 阅读 · 0 评论 -
PAT A1021 Deepest Root (25分)
PAT A1021 Deepest Root 25分原题大体题意思路代码运行结果原题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 called th原创 2020-09-01 20:30:33 · 140 阅读 · 0 评论 -
PAT A1046 Shortest Distance (20分)
1046 Shortest Distance 20分原题大体题意代码运行结果原题The task is really simple: given N exits 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 cas原创 2020-09-01 18:16:57 · 101 阅读 · 0 评论 -
PAT A1013 Battle Over Cities (25分)
PAT A1013 Battle Over Cities 25分原题大体题意思路代码运行结果原题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 r原创 2020-09-01 17:43:17 · 125 阅读 · 0 评论 -
PAT A1119 Pre- and Post-order Traversals (30分)
1119 Pre- and Post-order Traversals 30分原题大体题意思路代码运行结果原题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, or preorder and inorder原创 2020-09-01 14:44:27 · 207 阅读 · 0 评论 -
PAT A1110 Complete Binary Tree (25分)
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) which is the原创 2020-09-01 11:33:43 · 115 阅读 · 0 评论 -
PAT A1102 Invert a Binary Tree (25分)
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 fuck off.Now it’s your turn to prove that Y原创 2020-09-01 10:47:54 · 92 阅读 · 0 评论 -
PAT A1099 Build A Binary Search Tree (30分)
PAT A1099 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 less than the node’s key.The right su原创 2020-09-01 10:38:19 · 90 阅读 · 0 评论 -
PAT A1094 The Largest Generation (25分)
PAT A1094 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 with the largest population.Input Spe原创 2020-09-01 10:25:57 · 123 阅读 · 0 评论 -
PAT A1090 Highest Price in Supply Chain (25分)
@[TOC](PAT A1090 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.Starting from one root supplier, everyone on th原创 2020-08-31 20:20:29 · 114 阅读 · 0 评论 -
PAT A1086 Tree Traversals Again (25分)
PAT A1086 Tree Traversals Again 25分原题大体题意思路代码运行结果原题An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stack o原创 2020-08-31 20:02:05 · 90 阅读 · 0 评论 -
PAT A1079 Total Sales of Supply Chain (25分)
PAT A1079 Total Sales of Supply Chain 25分原题大体题意思路代码运行结果原题A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2020-08-31 18:32:51 · 158 阅读 · 0 评论 -
PAT A1066 Root of AVL Tree (25分)
PAT A1066 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 is done to原创 2020-08-31 18:15:22 · 93 阅读 · 0 评论 -
PAT A1064 Complete Binary Search Tree (30分)
PAT A1064 Complete 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 less than the node’s key.The right s原创 2020-08-31 17:01:52 · 107 阅读 · 0 评论 -
PAT A1053 Path of Equal Weight (30分)
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 along the path from原创 2020-08-31 16:06:25 · 92 阅读 · 0 评论 -
PAT A1043 Is It a Binary Search Tree (25分)
PAT A1043 Is It a Binary Search Tree 25分原题大体题意思路代码运行结果原题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 su原创 2020-08-31 14:45:23 · 109 阅读 · 0 评论 -
PAT A1020 Tree Traversals (25分)
1020 Tree Traversals 25分原题大体题意思路代码运行结果原题Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding bin原创 2020-08-31 13:56:00 · 105 阅读 · 0 评论 -
PAT A1004 Counting Leaves (30分)
PAT A1004 Counting Leaves 30分原题大体题意思路代码运行结果原题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 lin原创 2020-08-31 13:41:18 · 121 阅读 · 0 评论 -
PAT A1060 Are They Equal (25分)
1060 Are They Equal 25分原题大体题意思路代码运行结果原题If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. Now given the number of significant digits on原创 2020-08-31 13:27:04 · 88 阅读 · 0 评论 -
PAT A1027 Colors in Mars (20分)
PAT A1027 Colors in Mars 20分原题大体题意思路代码运行结果原题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 for Red, the middle 2 digits for Gr原创 2020-08-29 20:14:41 · 125 阅读 · 0 评论 -
PAT A1024 Palindromic Number (25分)
1024 Palindromic Number 25分原题大体题意思路代码运行结果原题A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Non-palin原创 2020-08-29 20:05:34 · 114 阅读 · 0 评论 -
PAT A1023 Have Fun with Numbers (20分)
PAT A1023 Have Fun with Numbers 20分原题大体题意思路代码运行结果原题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 consis原创 2020-08-29 19:43:18 · 127 阅读 · 0 评论 -
PAT A1019 General Palindromic Number (20分)
1019 General Palindromic Number 20分原题大体题意代码运行结果原题A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Alt原创 2020-08-29 18:52:23 · 79 阅读 · 0 评论 -
PAT A1015 Reversible Primes (20分)
PAT A1015 Reversible Primes 20分原题大体题意思路代码运行结果原题A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.No原创 2020-08-29 18:44:09 · 83 阅读 · 0 评论 -
PAT A1010 Radix (25分)
PAT A1010 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 o原创 2020-08-29 17:46:22 · 108 阅读 · 0 评论 -
PAT A1005 Spell It Right (20分)
@[TOC](PAT A1005 Spell It Right (20分))原题Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies原创 2020-08-29 17:27:23 · 100 阅读 · 0 评论 -
PAT A1065 A+B and C (64bit) (20分)
PAT A1065 A+B and C 64bit 20分 原题大体思路思路代码运行结果原题Given three integers A, B and C in [−263 ,263 ], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). Then T test原创 2020-08-29 17:08:34 · 178 阅读 · 0 评论 -
PAT A1058 A+B in Hogwarts (20分)
PAT A1058 A+B in Hogwarts 20分原题大体题意思路代码运行结果原题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原创 2020-08-29 16:22:27 · 135 阅读 · 0 评论 -
PAT A1002 A+B for Polynomials (25分)
PAT A1002 A+B for Polynomials 25分原题大体题意思路代码原题This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p原创 2020-08-29 15:51:16 · 169 阅读 · 0 评论 -
PAT A1042 Shuffling Machine (20分)
PAT甲级1042记录原题大体意思解题思路完整代码运行结果原题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 g原创 2020-08-17 22:36:45 · 119 阅读 · 0 评论 -
PAT专题训练——树
PAT专题训练——树树建树方式1. 用vector保存每一个非叶节点的孩子2. 二叉树左右指针之给定后序和中序建树3. 二叉树左右指针之给定先序和中序建树题型1. 层序遍历之vector形式的树2. 层序遍历之左右结点指针格式的树3. 后序遍历之左右结点指针格式的树4.树深之vector格式的树5.输出从根到叶子结点的全部路径树建树方式1. 用vector保存每一个非叶节点的孩子例如:A1...原创 2020-01-11 23:02:09 · 413 阅读 · 0 评论 -
PAT A1153 Decode Registration Card of PAT (25分)
PAT甲级1153记录原题大体翻译大体思路第一次编写提交结果第二次编写提交结果原题A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;...原创 2019-08-14 14:07:46 · 464 阅读 · 0 评论 -
PAT A1048 Find Coins (25分)
PAT甲级1048记录原题大体翻译思路第一次编写结果第二次编写结果原题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...原创 2019-07-08 10:37:05 · 170 阅读 · 0 评论 -
PAT A1041 Be Unique (20分)
PAT甲级1041记录原题大体翻译思路第一次编写结果原题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,10...原创 2019-07-08 20:02:02 · 136 阅读 · 0 评论