- 博客(56)
- 收藏
- 关注

原创 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

原创 PAT相关的基础知识
sort函数用法 c++下面记录最基础的sort函数的用法:bool cmp(int a,int b){ return a<b; //注意大于小于}int main(){ int a[10]; for(int i = 0; i < 10; i++) scanf("%d",&a[i]); sort(a, a + 10, cmp); return 0;}...
2020-01-11 23:02:41
1157

原创 PAT专题训练——树
PAT专题训练——树树建树方式1. 用vector保存每一个非叶节点的孩子2. 二叉树左右指针之给定后序和中序建树3. 二叉树左右指针之给定先序和中序建树题型1. 层序遍历之vector形式的树2. 层序遍历之左右结点指针格式的树3. 后序遍历之左右结点指针格式的树4.树深之vector格式的树5.输出从根到叶子结点的全部路径树建树方式1. 用vector保存每一个非叶节点的孩子例如:A1...
2020-01-11 23:02:09
413
原创 maven学习笔记
maven学习笔记maven基础依赖管理仓库仓库种类仓库关系一键构成常用命令生命周期maven导入jar包maven学习遇到的问题1.resources出现warning2.运行tomcat:run报错maven基础maven是一个项目管理工具依赖管理依赖管理就是maven对项目中jar包的管理过程。传统工程我们直接把jar包放置在项目中,而maven工程真正的jar包放置在仓库中,项目...
2021-04-28 18:23:52
111
原创 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
221
原创 PAT专题训练——数列
PAT专题训练——数列A1007 求和最大子序列A1029 求两个有序序列的中位数A1007 求和最大子序列A1029 求两个有序序列的中位数
2021-04-28 18:22:34
123
原创 杭电oj2000-2099难点记录
T2030 汉字识别汉字内码由两个字节组成,且最高位为1因此可以识别连续的两个字节且为负,即为一个汉字#include <iostream>using namespace std;#include <string>int main(){ int n; cin >> n; string str; getline(cin, str); while (n--) { getline(cin, str); int num = 0; int f
2021-03-28 01:15:14
856
原创 汉诺塔问题
汉诺塔问题简单汉诺塔变形一简单汉诺塔在一块铜板上有三根杆,最左边的杆上自上而下、由小到大顺序串着由n个圆盘构成的塔。目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动一个盘,且不允许大盘放在小盘的上面。1个盘子:将盘子从最左边移动到最右边,只需1步,即a[1]=12个盘子:将小盘子从最左边移动到中间,再将大盘子从最左边移动到最右边,最后将小盘子从中间移动到最右边,如下图1~3所示,共需3步,即a[2]=33个盘子就可以寻找到规律了,如图所示,共需7步,即a[3]=7综上所述,在三
2021-02-14 23:30:36
1306
原创 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
原创 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
139
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
113
原创 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
89
原创 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
原创 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
原创 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
原创 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
原创 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
原创 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
104
原创 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
原创 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
原创 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
120
原创 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
113
原创 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
126
原创 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
78
原创 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
80
原创 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
原创 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
98
原创 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
175
原创 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
130
原创 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
168
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人