自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小熊猫的博客

留下点足迹。。。

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

原创 PAT甲级——1089 Insert or Merge (插入、归并排序的非递归实现)

1089Insert or Merge(25分)According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one...

2019-07-11 17:12:42 237

原创 归并排序

归并排序的基本操作是将两个有序数组合并成一个有序数组,原理是运用分治思想,递归地将一个数组的左右两部分有序数列进行归并。C/C++的递归实现:// mergeSort.cpp : 递归写法//#include <stdio.h>#include <stdlib.h>#define elementType int//自定义数据类型using namesp...

2019-07-03 18:44:45 173

原创 PAT甲级——1090 Highest Price in Supply Chain (BFS或者DFS)

1090Highest 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.Star...

2019-06-30 15:30:15 280

原创 PAT甲级——1091 Acute Stroke (广度优先搜索BFS)

1091Acute Stroke(30分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each M...

2019-06-29 21:23:40 619 1

原创 PAT甲级——1092 To Buy or Not to Buy (字符串操作、映射)

1092To 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 th...

2019-06-24 16:09:26 162

原创 PAT甲级——1093 Count PAT's (逻辑类型的题目)

1093Count PAT's(25分)The stringAPPAPTcontains twoPAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and ...

2019-06-23 17:13:52 119

原创 PAT甲级——1094 The Largest Generation (树的遍历)

1094The 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 ...

2019-06-22 11:47:17 247

原创 PAT甲级——1095 Cars on Campus (排序、映射、字符串操作、题意理解)

1095Cars on Campus(30分)Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the ...

2019-06-20 21:18:33 467

原创 PAT甲级——1096 Consecutive Factors (数学题)

1096Consecutive Factors(20分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the thre...

2019-06-09 05:27:06 585 1

原创 PAT甲级——1097 Deduplication on a Linked List (链表)

1097Deduplication on a Linked List(25分)Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK,...

2019-06-07 22:11:21 235

原创 PAT甲级——1098 Insertion or Heap Sort (插入排序、堆排序)

1098Insertion or Heap Sort(25分)According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remo...

2019-06-05 21:09:04 383

原创 PAT甲级——1099 Build A Binary Search Tree (二叉搜索数)

1099Build 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...

2019-05-30 17:36:38 298

原创 PAT甲级——1100 Mars Numbers (字符串操作、进制转换)

1100Mars Numbers(20分)People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earth is called "jan, feb, mar, apr, may, jun, jly, aug, sep...

2019-05-29 21:06:47 232

原创 1014 福尔摩斯的约会 (字符匹配)

1014福尔摩斯的约会(20分)大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母D,代表星期四;第 2 对相同...

2019-05-28 13:53:52 108

原创 快速排序

快排主要运用了分治策略,每次选一个主元(主元放在它最终的位置上,在它左边的数都比它小,在它右边的数都比它大),从两边往中间寻找,当左边的元素大于等于主元、右边的元素小于等于主元时停下来交换左右两个元素,直到左边界不再小于右边界;然后递归地处理主元左边和右边的数据~~接下来有两个快排的写法:第一种是每次选择左边第一个数作为主元的快排,未做任何优化:int partition(int *...

2019-05-28 10:00:13 98

原创 PAT甲级——1101 Quick Sort (快速排序)

1101Quick Sort(25分)There is a classical process namedpartitionin the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the p...

2019-05-27 23:10:36 255

原创 PAT甲级——1102 Invert a Binary Tree (层序遍历+中序遍历)

1102Invert 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...

2019-05-26 16:08:36 191

原创 PAT甲级——1103 Integer Factorization (DFS)

1103Integer Factorization(30分)TheK−Pfactorization of a positive integerNis to writeNas the sum of theP-th power ofKpositive integers. You are supposed to write a program to find theK−P...

2019-05-26 12:34:06 369

原创 PAT甲级——1104 Sum of Number Segments (数学规律)

1104Sum of Number Segments(20分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segme...

2019-05-23 19:14:52 235

原创 PAT甲级——1105 Spiral Matrix (螺旋矩阵)

1105Spiral Matrix(25分)This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the uppe...

2019-05-23 17:19:20 217

原创 PAT甲级——1106 Lowest Price in Supply Chain (BFS)

1106Lowest 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.Start...

2019-05-22 15:39:39 421

原创 PAT甲级——1107 Social Clusters (并查集)

1107Social Clusters(30分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. Asocial clusteris a set of...

2019-05-21 16:47:44 236

原创 PAT甲级——1108 Finding Average (字符串)

1108Finding Average(20分)The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be l...

2019-05-21 10:21:36 291

原创 PAT甲级——1109 Group Photo (排序)

1109Group Photo(25分)Formation is very important when taking a group photo. Given the rules of formingKrows withNpeople as the following: The number of people in each row must beN/K(round...

2019-05-20 21:51:23 366

原创 PAT甲级——1110 Complete Binary Tree (完全二叉树)

1110Complete 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 g...

2019-05-18 17:30:50 614

原创 PAT甲级——1111 Online Map (单源最短路经的Dijkstra算法、priority_queue的使用)

1111Online Map(30分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other...

2019-05-14 23:02:12 197

原创 PAT甲级——1112 Stucked Keyboard (字符串操作+stl)

1112Stucked Keyboard(20分)On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen fo...

2019-05-09 16:47:30 363

原创 PAT甲级——1113 Integer Set Partition (排序)

1113Integer Set Partition(25分)Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA​1​​andA​2​​ofn​1​​andn​2​​numbers, respectively. LetS...

2019-05-08 12:29:47 305

原创 PAT甲级——1114 Family Property (并查集)

1114Family Property(25分)This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we ne...

2019-05-07 21:54:18 220

原创 PAT甲级——1115 Counting Nodes in a BST (二叉搜索树)

1115Counting 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 le...

2019-05-06 12:15:14 229

原创 PAT甲级——Eddington Number (水题)

1117Eddington Number(25分)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number",E-- that is, the maximum in...

2019-05-05 21:18:50 128

原创 PAT甲级——1116 Come on! Let's C (水题)

1116Come on! Let's C(20分)"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun...

2019-05-05 21:12:19 187

原创 PAT甲级——1118 Birds in Forest (并查集)

1118Birds in Forest(25分)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the...

2019-05-05 00:00:59 202

原创 PAT甲级——1119 Pre- and Post-order Traversals(先序+后序序列,建立二叉树)

1119Pre- 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 t...

2019-05-01 13:36:39 427

原创 PAT甲级——1120 Friend Numbers (又是set的应用)

1120Friend Numbers(20分)Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+...

2019-04-20 21:17:34 91

原创 PAT甲级——1121 Damn Single (C++的各种stl的使用)

"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each inpu...

2019-04-20 20:39:28 302

原创 PAT甲级——1122 Hamiltonian Cycle (哈密顿回路)

1122Hamiltonian Cycle(25分)The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".In this problem, you are sup...

2019-04-20 16:52:10 733

原创 PAT甲级——1123 Is It a Complete AVL Tree (完全AVL树的判断)

1123Is It a Complete AVL Tree(30分)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 ...

2019-04-18 23:49:01 259

原创 AVL树(自平衡二叉查找树)

这篇文章我是先在博客园发布的:https://www.cnblogs.com/yinhao-ing/p/10732866.html了解AVL树之前要先了解二叉查找树(BST),BST查找元素的时间复杂度平均是O(logN),最坏的情况是O(N),所有的元素都接在左子树(或者右子树)就相当于一串链表了。而AVL树会对子树过高的情况进行优化,这里有个平衡因子的概念,当前节点的平衡因子=左子树高度-...

2019-04-18 22:37:47 483

原创 PAT甲级——1124 Raffle for Weibo Followers (set或者unordered_set的应用)

1124Raffle for Weibo Followers(20分)John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N fo...

2019-04-12 21:14:06 119

空空如也

空空如也

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

TA关注的人

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