自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

lilian的博客

快乐学习!

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

原创 PAT A1115:Counting Nodes in a BST之搜索二叉树建树

题目描述1115 Counting Nodes in a BST (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 or equal to the node’s key.The right subtree o

2020-05-31 19:28:31 165

原创 PAT A1138:Postorder Traversal之前序和中序遍历建树

题目描述1138 Postorder Traversal (25分)Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal sequence of the corres

2020-05-31 18:34:37 220

原创 PAT A1119:Pre- and Post-order Traversals之前序、后序遍历序列建树

题目描述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 traversal

2020-05-31 16:36:26 222

原创 PAT A1086:Tree Traversals Again之前序和中序遍历建树&栈模拟建树过程

题目描述1086 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 operations are:

2020-05-31 13:37:21 195

原创 PAT A1099:Build A Binary Search Tree之中序遍历建树

题目描述1099 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 subtree of a node

2020-05-31 09:19:39 309 1

原创 PAT A1092:To Buy or Not to Buy之哈希映射

题目描述1092 To Buy or Not to Buy (20分)Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads.There were many colorful strings of beads. However the owner of the shop would only sell the strings in wh

2020-05-30 18:32:06 120

原创 PAT A1081:Rational Sum之分数加法

题目描述1081 Rational Sum (20分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in th

2020-05-30 17:29:43 194

原创 PAT A1083:List Grades之排序

题目描述1083 List Grades (25分)Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Inp

2020-05-29 20:38:24 142

原创 PAT A1074:Reversing Linked List之静态链表排序

题目描述1074 Reversing Linked List (25分)Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L.For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4, you must output 4

2020-05-29 20:18:55 182

原创 PAT A061:Dating

题目描述1061 Dating (20分)Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.It took him only a minute to figure out that those strange strings are actually referring to the co

2020-05-28 11:39:58 302

原创 PAT A1064:Complete Binary Search Tree之完全二叉搜索树

题目描述1064 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 subtree of a node

2020-05-28 10:20:08 202

原创 PAT 1068:Find More Coins之动态规划求解

题目描述1068 Find More Coins (30分)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 req

2020-05-27 19:55:58 248

原创 PAT A1048:Find Coins

题目描述1048 Find Coins (25分)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 requirem

2020-05-27 16:52:46 153

原创 PAT A1051:Pop Sequence之栈模拟

题目描述1051 Pop Sequence (25分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack.For example, if M i

2020-05-26 21:33:36 333

原创 PAT A1045:Favorite Color Stripe之动态规划

题目描述1045 Favorite Color Stripe (30分)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

2020-05-25 21:40:54 118

原创 PAT A1044:Shopping in Mars之二分查找

题目描述1044 Shopping in Mars (25分)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

2020-05-24 17:49:53 116

原创 PAT A1047:Student List for Course之sort排序

题目描述1047 Student List for Course (25分)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:Eac

2020-05-24 15:27:07 161

原创 PAT A1042:Shuffling Machine

题目描述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 gamblers by performing inadeq

2020-05-23 10:27:18 126

原创 PAT A1040:Longest Symmetric String最长子回文串

题目描述1040 Longest Symmetric String (25分)Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.

2020-05-23 09:19:26 155

原创 PAT A1039:Course List for Student之哈希

题目描述1039 Course List for Student (25分)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.Inp

2020-05-22 11:17:42 120

原创 PAT A1038:Recover the Smallest Number之sort排序

题目描述1038 Recover the Smallest Number (30分)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-

2020-05-22 08:27:06 117

原创 PAT A1037:Magic Coupon

题目描述1037 Magic Coupon (25分)The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop

2020-05-21 18:38:33 121

原创 PAT A1036:Boys vs Girls之sort排序

题目描述1036 Boys vs Girls (25分)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

2020-05-21 17:35:29 115

原创 PAT A1050:String Subtraction之哈希映射

题目描述1050 String Subtraction (20分)Given two strings S1 and S2, S=S1-S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1-S2 for any given strings. However, it might not be that simple

2020-05-20 20:52:09 183

原创 PAT A1035:Password

题目描述1035 Password (20分)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

2020-05-20 20:23:22 107

原创 PAT A1031:Hello World for U

题目描述1031 Hello World for U (20分)Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be printed in the original orde

2020-05-19 17:27:56 108

原创 PAT A1065:A + B and C(64bit)

题目描述1065 A+B and C (64bit) (20分)Given three integers A, B and C in [-2^63 ,2^63], 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 cases follow, each

2020-05-19 09:14:38 192

原创 PAT A1041:Be Unique之哈希

题目描述PAT 10411041 Be Unique (20分)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^4 ]. The first one who bets on a unique number wins

2020-05-18 21:03:56 175

原创 PAT A1029:Median之sort排序

题目描述PAT A10291029 Median (25分)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

2020-05-18 20:35:39 245 1

原创 STL之priority_queue常见用法详解

摘自胡凡的《算法笔记》,仅作记录用!前言:要使用优先对垒,应先添加头文件#include <queue> ,并在头文件下面加上using namespace std;一、priority_queue的定义其定义的写法和其他STL容器相同,typename可以是任意基本数据类型或容器priority_queue<typename> name;二、priority_queue容器内元素的访问和队列不一样的是,优先队列没有front()函数与back()函数,而只能通过top()

2020-05-14 17:03:26 415

原创 STL之queue的常见用法详解

摘自胡凡的《算法笔记》,仅作记录用!前言:要使用queue,应先添加头文件#include <queue> ,并在头文件下面加上using namespace std;一、queue的定义其定义的写法和其他STL容器相同,typename可以是任意基本数据类型或容器queue<typename> name;二、queue容器内元素的访问由于队列本身就是一种先进先出的限制性数据结构,因此在STL中只能通过front()来访问队首元素,或是通过back()来访问队尾元素三、q

2020-05-14 15:57:09 905

原创 STL之stack常见用法详解

摘自胡凡的《算法笔记》,仅作记录用!前言:要使用stack,应先添加头文件#include <stack>,并在头文件下面加上using namespace std;然后就可以使用了一、stack的定义其定义的写法和其他STL容器相同,typename可以任意基本数据类型或容器stack< typename > name;二、stack容器内元素的访问由于栈本身就是一种后进先出的数据结构,在STL的stack中只能通过top()来访问栈顶元素三、stack常见函数

2020-05-14 15:40:34 1426

原创 STL之pair常见用法详解

摘自胡凡的《算法笔记》,仅作记录用!前言:pair可以将两个元素绑在一起作为一个合成元素,如果要使用pair,则需要添加utility头文件,即#include<utility>,除此之外,还需要添加using namespace std;。注意,由于map的内部实现中涉及pair,就不需要额外再去添加utility头文件了。因此只需要添加头文件map即可一、pair的定义pair有两个参数,分别对应first和second的数据类型,它们可以是任意基本数据类型或容器,可以使用p

2020-05-14 15:27:31 1297

原创 PAT A1030:Travel Plan之Dijkstra求解

题目描述1030 Travel Plan (30分)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

2020-05-10 11:04:21 142

原创 PAT A1076:Forwards on Weibo之BFS求解

题目描述1076 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 makes a post on W

2020-05-09 15:06:52 156

原创 PAT A1034:Head of a Gang之DFS求解

题目描述1034 Head of a Gang (30分)One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of a

2020-05-09 10:40:42 147

原创 PAT A1053:Path of Equal Weight

题目描述1053 Path of Equal Weight (30分)Given a non-empty tree with root R, and with weight WiW_iWi​ assigned to each tree node TiT_iTi​. 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 R to any le

2020-05-08 21:04:22 128

原创 PAT A1059:Prime Factors

题目描述1059 Prime Factors (25分)Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N=p1k1×p2k2×…×pmkmN = p_1^{k1}\times p_2^{k2}\times …\times...

2020-05-07 18:41:46 154

原创 PAT A1069:The Black Hole of Numbers

题目描述1069 The Black Hole of Numbers (20分)For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing or...

2020-05-07 16:55:25 85

原创 algorithm头文件下的常用函数

来自胡凡的《算法笔记》

2020-05-07 11:45:57 177

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除