![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
算法
算法课学习记录
retrogogogo
大学生你不学习?
展开
-
解 poj1502-MPI Maelstrom(单源最短路径的广搜与dijkstra实现)
文章目录Description题意解析1.队列式分支限界法广搜2.优先队列式分支限界法广搜3.Dijkstra算法DescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee’原创 2020-12-17 15:45:18 · 217 阅读 · 2 评论 -
字符串魔法hard(前后缀与贪心)
字符串魔法hard(前后缀与贪心)链接:https://ac.nowcoder.com/acm/contest/9680/C来源:牛客网description:白浅获得了一个仅由A和B组成的字符串。他可以至多使用一次魔法来改变字符串。 魔法:选择一个子串,满足子串中 A 的数量等于 B的数量,然后按字典序从小到大排序这个子串,即变成形如AAA…AAABBB…BBB这样的字符串(A和B的数量均与原来的子串相同)。他想知道,在他至多使用一次魔法后,这个字符串能够出现的最长的字典序不递减的子串的长度原创 2020-12-08 14:02:43 · 737 阅读 · 0 评论 -
HDU - 6003 Problem Buyer题解(贪心选择算法,鸽巢原理,优先队列维护)
HDU - 6003 Problem Buyer题解(贪心选择算法,鸽巢原理,优先队列维护)HDU6003原题点这里原创 2020-12-22 01:14:10 · 277 阅读 · 0 评论 -
DP动态规划--基础题-Alphacode(poj-2033)
DP基础题-Alphacode来源 poj-2033原题链接 题目:Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages:Alice: “Let’s just use a very simple code: We’ll assign ‘A’ the code word 1, ‘B’ will be 2, and so on down to原创 2020-10-04 23:59:16 · 316 阅读 · 0 评论 -
DP动态规划--基础题-滑雪(POJ-1088)
DP–基础题-滑雪原创 2020-10-08 00:09:58 · 556 阅读 · 1 评论 -
DP动态规划--乡村邮局问题-Post Office(POJ-1160)
DP–乡村邮箱问题-Post Office原题点这里题目There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in th原创 2020-10-22 00:20:11 · 1859 阅读 · 0 评论 -
DP动态规划--最大子段和问题
DP–最大子段和问题(动态规划)问题:有n个整数组成一个a1,a2,a3,… ,an序列。求其子段和的最大值(子段是连续的)比如{-2,11,-4,13,-5,-2},最大子段和就是11-4+13=20解题思路:这是一个很典型的动态规划性质的题目,我们先设置一个dp数组dp[i]表示以a[i]为结尾的子段的最大子段和。这里注意一定要以a[i]结尾而不是a[1]到a[i]间任意子段,因为这样有利于利用与维护其最优子结构性质得到递推式:(1.)dp[i]=dp[i-1]+a[i]---原创 2020-11-04 22:22:24 · 1179 阅读 · 0 评论 -
DP动态规划--最大子矩阵和问题(最大子段问题的推广即二维最大子段和问题)-To the Max(POJ - 1050题解)
DP–最大子矩阵和问题(最大子段问题的推广,即二维最大子段和问题 )-To the MaxPOJ - 1050原题点这里题目Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is原创 2020-11-04 11:53:25 · 1192 阅读 · 1 评论 -
DP动态规划--背包问题变题-Knapsack problem(FZU-2214)
DP–背包问题变题 Knapsack problem原题点这里题目Given a set of n items, each with a weight w[i] and a value v[i], determine a way to choose the items into a knapsack so that the total weight is less than or equal to a given limit B and the total value is as large as原创 2020-11-01 21:29:53 · 325 阅读 · 0 评论 -
DP动态规划--m处理器问题- m processors(FZU - 1442)
DP–m处理器问题- m processors(FZU - 1442)DescriptionThere are n data packets and m processors in a network communication system. In this problem, you need to distribute the n data packets to the m processors so that the workload of each processor is as balanc原创 2020-11-06 23:56:38 · 2028 阅读 · 0 评论 -
DP动态规划-爬塔(双层dp)
DP动态规划-爬塔(双层dp)比赛来源:牛客 - 中国计量大学现代科技学院第四届“中竞杯”程序设计校赛题目--------F题description:高川最喜欢的游戏当属 Slay the Spire,这是一款爬塔游戏,你需要从一座塔的底部一直爬到顶部,在爬塔的过程中,塔的每一层都有许多的宝物等你来拿。高川从塔的左侧开始攀爬,从底部爬到顶部,再从右侧从顶部逐步下到底部。塔总共有 n 层,每一层都有很多宝物从左到右排列。在左侧攀爬时,他只能从每层的最左边按顺序取宝物,在右侧下降时,他只能从每层的最原创 2020-12-08 01:27:54 · 599 阅读 · 0 评论 -
c++/c 大整数乘法的分治与递归实现(string存储)
c++/c 大整数乘法的递归实现(string存储)不多说,看代码,速度不快,但重要在思想与细节。#include<iostream>#include<algorithm>#include<string>#include<ctime>using namespace std;clock_t START, END;string add(string x, string y) {//大整数加法 string z; int nx = x.size(原创 2020-10-29 00:36:04 · 922 阅读 · 0 评论 -
分治递归法的算法复杂性计算
分治法的算法复杂性计算分治法一般是用递归实现的,且往往是均分,最常见的就是二分算法。而在计算分治法的算法复杂性时,我们往往能得到这样一个关于复杂性公式T(n)的递推式:其中,n为数据规模,k为分治后子规模运算的数量,m为规模的划分数,一般为二分,即m=2。f(n)为分治后需要进行的额外计算复杂度,一般为将多个划分连接起来的运算。对于此类计算,我们可以得到以下计算公式:f(n)=O(1)k=1 —>T(n)=O( n^logm(k) );k>1 —&原创 2020-11-13 15:47:39 · 793 阅读 · 0 评论