自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

且慢

愿过往惆怅 化他日酒香 偕肝胆比翼 书来日方长

  • 博客(62)
  • 资源 (1)
  • 收藏
  • 关注

原创 PAT (Advanced Level) Practice 1126 Eulerian Path (25分) (欧拉路、欧拉回路的判断 DFS/并查集加优化)

1.题目In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They wer...

2020-03-31 20:42:47 163

原创 PAT (Advanced Level) Practice 1129 Recommendation System (标记+排序)

1.题目Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user's preference by the number o...

2020-03-27 16:34:13 113

原创 PAT (Advanced Level) Practice 1135 Is It A Red-Black Tree (30分) (红黑树知识+建树+判断)

1.题目There is a kind of balanced binary search tree namedred-black treein the data structure. It has the following 5 properties:(1) Every node is either red or black. (2) The root is black. (3)...

2020-03-26 17:04:23 152

原创 PAT (Advanced Level) Practice 1134 Vertex Cover (25分) (存边+标记点!!)

1.题目Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tel...

2020-03-26 10:17:56 131

原创 PAT (Advanced Level) Practice 1133 Splitting A Linked List (25分) (静态链表的遍历)

1.题目Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all thos...

2020-03-25 21:30:12 84

原创 PAT (Advanced Level) Practice 1139 First Contact (30分) (unordered_map用来标记+哈希)

1.题目Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her dire...

2020-03-25 21:08:34 511

原创 PAT (Advanced Level) Practice 1132 Cut Integer (20分) (atoi、stoi区别、stringstream使用)

1.题目Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is inter...

2020-03-25 20:59:11 114

原创 PAT (Advanced Level) Practice 1138 Postorder Traversal (25分) (不键树、法一找规律法二先序中序变后序)

1.题目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 traver...

2020-03-23 18:39:42 97

原创 PAT (Advanced Level) Practice 1137 Final Grading (25分)

1.题目For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 point...

2020-03-23 10:59:16 135

原创 PAT (Advanced Level) Practice 1136 A Delayed Palindrome (20分)

1.题目Consider a positive integerNwritten in standard notation withk+1digitsa​i​​asa​k​​⋯a​1​​a​0​​with0≤a​i​​<10for allianda​k​​>0. ThenNispalindromicif and only ifa​i​​=a​k−i...

2020-03-23 10:57:57 90

原创 PAT (Advanced Level) Practice 1142 Maximal Clique (25分) (算法设计)

1.题目Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one mo...

2020-03-23 10:47:54 119

原创 PAT (Advanced Level) Practice 1141 PAT Ranking of Institutions (25分)

1.题目After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file...

2020-03-23 10:41:44 115

原创 PAT (Advanced Level) Practice 1153 Decode Registration Card of PAT (25分)

1.题目A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test s...

2020-03-23 10:39:29 111

原创 PAT (Advanced Level) Practice 1152 Google Recruitment (20分)

1.题目In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-d...

2020-03-23 10:38:25 99

原创 PAT (Advanced Level) Practice 1143 Lowest Common Ancestor (30分) (LCA+二叉搜索树)

1.题目The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree whic...

2020-03-23 10:36:00 168

原创 PAT (Advanced Level) Practice 1147 Heaps (30分) (最大最小堆的判断 两种方法)

1.题目In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal...

2020-03-22 12:07:38 234

原创 PAT (Advanced Level) Practice 1146 Topological Order (25分) (拓扑序列的判断)

1.题目This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program t...

2020-03-21 19:09:31 111

原创 PAT (Advanced Level) Practice 1145 Hashing - Average Search Time (25分) (哈希平方探测,哈希插入、查找范围不同)

1.题目The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the avera...

2020-03-21 09:57:38 115

原创 PAT (Advanced Level) Practice 1144 The Missing Number (20分)

1.题目Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first li...

2020-03-20 08:47:50 50

原创 LCA算法实际应用 PAT (Advanced Level) Practice 1151 LCA in a Binary Tree (30分) 四种方法完成题目+tarjan详细讲解!

1.题目The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LC...

2020-03-19 21:49:10 338

原创 记笔记最好用的超高颜值软件之一!Typora 你值得拥有!

之前一直在寻找一款比较好用的记笔记软件,OneNote很强大,但是有时总是出现同步失败的问题,而且对代码类型的笔记不太友好。之后意外了解到markdown(一种富文本的记笔记形式),类似CSDN,于是就了解到Typora 这款颜值超高还免费的软件!它支持多种好看的主题,支持代码高亮,文字注释...

2020-03-16 14:54:21 14267 1

原创 PAT (Advanced Level) Practice 1150 Travelling Salesman Problem (25分) (正常思路)

1.题目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 an...

2020-03-13 10:12:10 165

原创 PAT (Advanced Level) Practice 1154 Vertex Coloring (25分) (直接存边遍历)

1.题目Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at mostkcolors is called a (pro...

2020-03-12 22:46:58 157

原创 PAT (Advanced Level) Practice 1155 Heap Paths (30分) (递归+数组建树,递归+vector输出,make_heap判断)

1.题目In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal...

2020-03-12 19:28:08 374

原创 PAT (Basic Level) Practice (中文) 1095 解码PAT准考证 (25分) (unordered_map的使用 多做几遍!!)

1.题目PAT 准考证号由 4 部分组成:第 1 位是级别,即T代表顶级;A代表甲级;B代表乙级; 第 2~4 位是考场编号,范围从 101 到 999; 第 5~10 位是考试日期,格式为年、月、日顺次各占 2 位; 最后 11~13 位是考生编号,范围从 000 到 999。现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息。输入格式:输入首先...

2020-03-09 17:29:27 79

原创 1094 谷歌的招聘 (20分) (有小问题待大神求解!!!!!!!!!!!!)

1.题目本题要求你编程解决一个更通用的问题:从任一给定的长度为 L 的数字中,找出最早出现的 K 位连续数字所组成的素数。输入格式:输入在第一行给出 2 个正整数,分别是 L(不超过 1000 的正整数,为数字长度)和 K(小于 10 的正整数)。接下来一行给出一个长度为 L 的正整数 N。输出格式:在一行中输出 N 中最早出现的 K 位连续数字所组成的素数。如果这样的素数不存...

2020-03-09 12:09:30 1148 1

原创 PAT (Basic Level) Practice (中文) 1093 字符串A+B (20分)

1.题目给定两个字符串A和B,本题要求你输出A+B,即两个字符串的并集。要求先输出A,再输出B,但重复的字符必须被剔除。输入格式:输入在两行中分别给出A和B,均为长度不超过10​6​​的、由可见 ASCII 字符 (即码值为32~126)和空格组成的、由回车标识结束的非空字符串。输出格式:在一行中输出题面要求的A和B的和。输入样例:This...

2020-03-09 10:50:44 166 1

原创 PAT (Basic Level) Practice (中文)1092 最好吃的月饼 (20分)

1.题目月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出全国各地各种月饼的销量,要求你从中找出销量冠军,认定为最好吃的月饼。输入格式:输入首先给出两个正整数N(≤1000)和M(≤100),分别为月饼的种类数(于是默认月饼种类从 1 到N编号)和参与统计的城市...

2020-03-09 10:39:22 174

原创 PAT (Basic Level) Practice (中文) 1091 N-自守数 (15分)

1.题目如果某个数K的平方乘以N以后,结果的末尾几位数等于K,那么就称这个数为“N-自守数”。例如3×92​2​​=25392,而25392的末尾两位正好是92,所以92是一个3-自守数。本题就请你编写程序判断一个给定的数字是否关于某个N是N-自守数。输入格式:输入在第一行中给出正整数M(≤20),随后一行给出M个待检测的、不超过 1000 的正...

2020-03-09 10:31:37 81

原创 PAT (Basic Level) Practice (中文)1090 危险品装箱 (25分) (单身狗进阶版 使用map+ vector+数组标记)

1.题目集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里。比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸。本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里。输入格式:输入第一行给出两个正整数:N(≤10​4​​) 是成对的不相容物品的对数;M(≤100) 是集装箱货品清单的单数。随后数据分两大块给出。第一...

2020-03-09 10:09:36 269

原创 PAT (Basic Level) Practice (中文) 1088 三人行 (20分)

1.题目子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。”本题给定甲、乙、丙三个人的能力值关系为:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍;乙的能力值是丙的 Y 倍。请你指出谁比你强应“从之”,谁比你弱应“改之”。输入格式:输入在一行中给出三个数,依次为:M(你自己的能力值)、X 和 Y。三个...

2020-03-08 21:49:43 132

原创 PAT (Basic Level) Practice (中文) 1087 有多少不同的值 (20分)

1.题目当自然数n依次取 1、2、3、……、N时,算式⌊n/2⌋+⌊n/3⌋+⌊n/5⌋有多少个不同的值?(注:⌊x⌋为取整函数,表示不超过x的最大自然数,即x的整数部分。)输入格式:输入给出一个正整数N(2≤N≤10​4​​)。输出格式:在一行中输出题面中算式取到的不同值的个数。输入样例:2017输出样例:14802.题目分析...

2020-03-08 21:18:15 83

原创 PAT (Basic Level) Practice (中文)1086 就不告诉你 (15分)

1.题目做作业的时候,邻座的小盆友问你:“五乘以七等于多少?”你应该不失礼貌地围笑着告诉他:“五十三。”本题就要求你,对任何一对给定的正整数,倒着输出它们的乘积。输入格式:输入在第一行给出两个不超过 1000 的正整数 A 和 B,其间以空格分隔。输出格式:在一行中倒着输出 A 和 B 的乘积。输入样例:5 7输出样例:532.代码#incl...

2020-03-08 21:05:32 674

原创 PAT (Basic Level) Practice (中文) 1085 PAT单位排行 (25分) (map搜索+set排序+并列进行排行)

1.题目每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜。本题就请你实现这个功能。输入格式:输入第一行给出一个正整数 N(≤10​5​​),即考生人数。随后 N 行,每行按下列格式给出一个考生的信息:准考证号 得分 学校其中准考证号是由 6 个字符组成的字符串,其首字母表示考试的级别:B代表乙级,A代表甲级,T代表顶级;得分是 [0, 100] 区间内的整数;学...

2020-03-08 21:00:00 106

原创 PAT (Basic Level) Practice (中文) 1083 是否存在相等的差 (20分)

1.题目给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差?输入格式:输入第一行给出一个正整数 N(2≤N≤10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。输出格式:按照“...

2020-03-08 18:38:31 72

原创 PAT (Basic Level) Practice (中文) 1082 射击比赛 (20分)

1.题目本题目给出的射击比赛的规则非常简单,谁打的弹洞距离靶心最近,谁就是冠军;谁差得最远,谁就是菜鸟。本题给出一系列弹洞的平面坐标(x,y),请你编写程序找出冠军和菜鸟。我们假设靶心在原点(0,0)。输入格式:输入在第一行中给出一个正整数 N(≤10 000)。随后 N 行,每行按下列格式给出:ID x y其中ID是运动员的编号(由 4 位数字组成);x和y是...

2020-03-08 17:17:27 139

原创 PAT (Basic Level) Practice (中文) 1081 检查密码 (15分)

1.题目本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点.,还必须既有字母也有数字。输入格式:输入第一行给出一个正整数 N(≤100),随后 N 行,每行给出一个用户设置的密码,为不超过 80 个字符的非空字符串,以回车结束。输出格式:对每个用户的密码,在一行中输出系统反馈信息...

2020-03-08 17:09:47 1352

原创 PAT (Basic Level) Practice (中文) 1080 MOOC期终成绩 (25分) (使用map 代替搜索、使用multiset实现排序(注意复习!))

1.题目对于在中国大学MOOC(http://www.icourse163.org/)学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的在线编程作业分,然后总评获得不少于60分(满分100)。总评成绩的计算公式为G=(G​mid−term​​×40%+G​final​​×60%),如果G​mid−term​​>G​final​​;否则总评G就是G​...

2020-03-08 16:45:59 114

原创 PAT (Basic Level) Practice (中文) 1079 延迟的回文数 (20分) (大数加法)

1.题目给定一个k+1位的正整数N,写成a​k​​⋯a​1​​a​0​​的形式,其中对所有i有0≤a​i​​<10且a​k​​>0。N被称为一个回文数,当且仅当对所有i有a​i​​=a​k−i​​。零也被定义为一个回文数。非回文数也可以通过一系列操作变出回文数。首先将该数字逆转,再将逆转数与该数相加,如果和还不是一个回文数,就重复这个逆转再相加的操作...

2020-03-08 15:40:35 120

原创 PAT (Basic Level) Practice (中文) 1078 字符串压缩与解压 (20分) (字符转数字——栈存放)

1.题目文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一个连续的片段用这个字符和片段中含有这个字符的个数来表示。例如ccccc就用5c来表示。如果字符没有重复,就原样输出。例如aba压缩后仍然是aba。解压方法就是反过来,把形如5c这样的表示恢复为ccccc。本题需要你根据压缩或解压的要求,对给定字符串进行处理。这里我们简单地假设原始字符串是完...

2020-03-08 11:37:10 138

波士顿房价预测数据集.csv

波士顿房价预测案例中CSV格式有表头,可用于深度学习中的数据集,12类影响房价的数据乙级最后的平均房价都有

2020-02-05

空空如也

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

TA关注的人

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