- 博客(23)
- 资源 (9)
- 收藏
- 关注
原创 PATj甲级 1087 All Roads Lead to Rome (30 分)dijkstra + dfs
1087 All Roads Lead to Rome (30 分)Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most hap...
2018-10-25 22:19:42 182
转载 upper_bound()和low_bound函数的基本使用和理解
原文链接:https://blog.csdn.net/sdz20172133/article/details/80101838前提:一个非降序列!!!!!!lower_bound()函数使用:它的参数就是:1.一个数组元素的地址(或者数组名来表示这个数组的首地址,用来表示这个数组的开头比较的元素的地址,不一定要是首地址,只是用于比较的“首”地址),2.一个数组元素的地址(对应的...
2018-10-23 20:17:02 313
原创 C++ 堆排
堆排的一开始要先建堆,这里是按从小到大排序,建立的是最大堆。注意这里的堆排要求数组的下标是从一开始,方便操作。堆排序的两个步骤:(1)从非叶子结点开始依次“下沉”,构建出最大堆。(2)依次将堆顶元素删除,此时新交换的根结点要”下沉".#include <iostream>using namespace std;void shift(int arr[],in...
2018-10-23 19:21:53 371
原创 二分查找:当有多个元素值与目标元素相等时,返回最左边和最右边一个元素的下标
参考链接: http://blog.chinaunix.net/uid-27103408-id-3761907.html函数使用二分查找搜索一个增序的数组,当有多个元素值与目标元素相等时,返回最左边一个元素的下标,目标元素不存在时返回-1。代码如下:#include <iostream>using namespace std;int BinarySearch(int...
2018-10-23 10:57:50 3600 2
原创 PAT甲级 1080 Graduate Admission (30 分)排序
1080 Graduate Admission (30 分)It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a p...
2018-10-22 22:31:05 172
原创 PAT甲级 1077 Kuchiguse (20 分)字符串处理
1077 Kuchiguse (20 分)The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such ...
2018-10-21 21:39:35 318
原创 PAT甲级 1078 Hashing (25 分)(二次方探查法)
1078 Hashing (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined ...
2018-10-21 21:01:52 399 1
原创 1084 Broken Keyboard (20 分)has散列
1084 Broken Keyboard (20 分)On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a st...
2018-10-21 16:15:50 259
原创 PAT甲级 1083 List Grades (25 分)排序水题
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 rec...
2018-10-21 12:20:23 218
原创 1082 Read Number in Chinese (25 分)字符串处理
1082 Read Number in Chinese (25 分)Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 ...
2018-10-21 12:11:18 996
原创 PAT 1081 Rational Sum (20 分)分数的四则运算
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 ...
2018-10-18 10:33:42 402
原创 实习所面到的算法题
今日头条iOS上海:1.二叉树的先中后序遍历,用非递归的形式。2.用两个栈实现一个队列功能。百度测开上海:1.输出链表的倒数第K个结点。
2018-10-17 18:12:54 122
原创 PAT甲级 1079 Total Sales of Supply Chain (25 分)DFS
参考链接:https://www.cnblogs.com/grglym/p/7922417.html1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in...
2018-10-16 21:54:46 218
原创 PAT甲级 1076 Forwards on Weibo (30 分)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 wi...
2018-10-08 22:04:44 205
原创 判断一棵树是否为另一棵树的子树
参考链接:判断一棵树是否为另一棵树的子树思路:1、原二叉树走前序遍历,试图发现哪个节点的值和被判断子树的根节点相同;如果一直到最后也没有找到那么肯定不是2、如果找到了,就两个二叉树一起前序遍历,试图发现两个二叉树同时遍历完成,且同样的左右子树遍历过程中的节点值均相同,同时遍历完成说明有相同的形状,左右子树遍历过程中的节点值均相同说明两个二叉树不仅形状一样,值也是一样,则可以认为是子...
2018-10-08 21:20:52 1383 1
原创 C++ 反转链表
参考链接:链表翻转的图文讲解(递归与迭代两种实现)这里主要写了非递归的实现反转的函数实现:LNode *reverList(LNode *&head){ if(head == nullptr || head->next == nullptr) return head; LNode *pre = nullptr,*cur = head;//注意pre的初始值是...
2018-10-06 19:09:44 373
转载 PAT甲级真题目录(按题型整理)
原文链接: PAT甲级真题目录(按题型整理)最短路径1003. Emergency (25)-PAT甲级真题(Dijkstra算法) 1018. Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) 1030. Travel Plan (30)-PAT甲级真题(Dijkstra + DFS,输出路径,边权) 1087. All Roa...
2018-10-06 18:57:28 16844 3
原创 PAT甲级 1074 Reversing Linked List (25 分)数组链表
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 Lbeing 1→2→3→4→5→6, if K=3, then yo...
2018-10-06 18:54:08 142
原创 PAT甲级 1073 Scientific Notation (20 分)String的使用
1073 Scientific Notation (20 分)Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-...
2018-10-06 18:46:30 111
原创 PAT甲级 1072 Gas Station (30 分)Dijkstra
1072 Gas Station (30 分)A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must g...
2018-10-05 21:21:30 387
原创 PAT甲级 1071 Speech Patterns (25 分)map映射,STL的使用
1071 Speech Patterns (25 分)People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can ...
2018-10-05 19:54:52 268
原创 PAT甲级 1070 Mooncake (25 分)贪心算法
1070 Mooncake (25 分)Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the ...
2018-10-05 19:45:09 231
原创 PAT甲级 1069 The Black Hole of Numbers (20 分)STL的使用
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 order...
2018-10-05 19:35:18 217
吴恩达2014机器学习作业(全部完整!!!作业全部代码已补全且运行结果无误!!!)
2018-06-20
吴恩达机器学习作业(完整版!!亲自做过!)
2018-05-29
Python网络数据采集
2018-04-27
机器学习实战源代码
2018-04-27
机器学习实战
2018-04-27
Effective C++中文版
2018-04-27
OpenCV3-毛星云编程入门
2018-04-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人