- 博客(35)
- 资源 (2)
- 收藏
- 关注
转载 (转载)趣写算法系列之--匈牙利算法
转自:http://blog.csdn.net/dark_scope/article/details/8880547【书本上的算法往往讲得非常复杂,我和我的朋友计划用一些简单通俗的例子来描述算法的流程】匈牙利算法是由匈牙利数学家Edmonds于1965年提出,因而得名。匈牙利算法是基于Hall定理中充分性证明的思想,它是部图匹配最常见的算法,该算法的核心就是寻找增广路径,它
2017-08-23 14:05:03 277
原创 poj-1330-Nearest Common Ancestors-LCA(RMQ)
题目传送门:http://poj.org/problem?id=1330什么是LCA?公共祖先简称LCA(Lowest Common Ancestor),所谓LCA,是当给定一个有根树T时,对于任意两个结点u、v,找到一个离根最远的结点x,使得x同时是u和v的祖先,x 便是u、v的最近公共祖先。 额 ̄へ ̄ 听说有好多种解法,但是我就先发一种,其他回来补上 开始
2017-08-15 19:19:25 286 1
原创 51node-1174-区间中最大的数(RMQ)
题目传送门:http://www.51nod.com/onlineJudge/questionCode.html?problemId=1174什么是RMQ?RMQ(RangeMinimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j 开始啦!假设数列A: 3 2 4 5
2017-08-15 10:09:00 296
原创 hdu-2544-最短路-(bellman-ford、dijkstra、floyd、SPFA算法)
最短路问题在程序竞赛中是经常出现的内容,解决单源最短路经问题的有bellman-ford和dijkstra两种算法,其中,dijikstra算法是对bellman的改进。同时介绍了floyd算法、SPFA算法。 题目传送门:https://vjudge.net/problem/HDU-2544最短路在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的
2017-07-31 21:20:36 654
原创 hdu-1010-Tempter of the Bone
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone
2017-03-08 20:11:44 354
原创 zzuli-2276-跳一跳
题目链接:http://acm.zzuli.edu.cn/problem.php?id=2276 题目描述 今天跳跳去公园游玩,第一个游戏就难倒了跳跳,游戏规则是跳跳站在一个面积无限大的矩形土地上,开始时跳跳在左上角(即第一行第一列),每一次跳跳都可以选择一个右下方格子,并瞬间跳过去(如从下图中的红色格子能直接跳到蓝色格子),求跳到第n行第m列的格子有多少种方案,答案对1000000007取模...
2018-05-20 10:59:46 282
转载 (转)卡特兰数——Catalan数(从一道腾讯笔试题引发的学习和思考)
原文:https://blog.csdn.net/u012333003/article/details/23791979?utm_source=tuicool&utm_medium=referral一、故事背景卡特兰数是离散数学中的一个重要数列,是很多生活场景的一个抽象,比如买早餐啦,买电影票啦等等。在很多大公司的笔试或者面试题中也常涉及到。二、卡特兰数的引出在x-y坐...
2018-05-19 14:25:43 338
原创 codeblocks主题修改文件
修改方法参照本页面:http://blog.csdn.net/blue___fox/article/details/48063969 提供一个自己改过的主题,还不错!!!! 下载链接:http://download.csdn.net/download/newproblems/10230166推荐bigdz和bigdzfour效果见下图 bigdz bigdzone bigdztw
2018-01-29 17:21:12 553
原创 1.26
一、Map和Multimap/*代码大致思路:函数部分print 输出一个mapprintM 输出一个multimapprintGprintG_MprintL_M*/#include #include using namespace std;typedef pairint, double> CustomPair;void print(mapint, double
2018-01-28 11:09:43 164
原创 2018.2.23
OOPObject Oriented Programming 面向对象的编程IDE集成开发环境常见头文件 文件名 包含 iostream cin\cout\endl要点1. 2. 3.常见整型的范围 4. 按位运算符1.移位运算符 名称 符号 值 左移运算符 &...
2018-01-24 14:37:07 199 1
原创 set容器
1、基本用法begin() ,返回set容器的第一个元素end() ,返回set容器的最后一个元素clear() ,删除set容器中的所有的元素empty() ,判断set容器是否为空max_size() ,返回set容器可能包含的元素最大个数size() ,返回当前set容器中的元素个数rbegin ,返回的值和end()相同rend()
2017-11-12 21:32:32 226 1
原创 三点求平面方程、平面法向量和点到平面的距离
已知三点p1(x1,y1,z1),p2(x2,y2,z2),p3(x3,y3,z3),要求确定的平面方程,关键在于求出平面的一个法向量为此做向量p1p2(x2-x1,y2-y1,z2-z1), p1p3(x3-x1,y3-y1,z3-z1),平面法线和这两个向量垂直,因此法向量n:平面方程:a(x-x1)+b(y-y1)+ c(z-z1)=0;d=-a*x1
2017-08-28 17:48:44 23189 1
原创 lightoj-1138-Trailing Zeroes (III) -二分查找
题目传送门:https://vjudge.net/problem/LightOJ-1138题意:给你一个数字,这个数字代表N!后面有几个0。给出这个数字,计算N的值。解题思路:任何质因数都可以写成素数相乘的形式。所以计算一个数的阶乘后面几个0,只需计算这个数包含多少5即可。ac代码;#include #include #include #i
2017-08-26 11:27:51 244
原创 lightoj-1234-调和级数
题目传送门:https://vjudge.net/problem/LightOJ-1234方法一:(有点投机取巧了)公式如下: 其中r为常数,r=0.57721566490153286060651209(r就是欧拉常数)but n大的时候,精确度才高。所以数小的时候就打表。特别注意,由于题目要求精度为10^-8,常数r为有限位数,所以正常利用这个公式,并不能达到精
2017-08-26 10:49:30 415
原创 hdu-3249-Girls' research -mancher
题目传送门:https://vjudge.net/problem/HDU-3294就是manacher求一下回文串,同时记录一下起始位置和长度,输出。先进行字母的替换。感觉,最不好推得是,根据变形后的字符串去找现在字符串的位置。 l = (i - 1)/2 - (ans - 1)/2; r = l + ans - 2;
2017-08-26 10:37:40 211
原创 hdu-6130-Kolakoski
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6130Kolakoski序列是一个仅由1和2组成的无限数列,是一种通过“自描述”来定义的数列[1] 。他的前几项为1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,2,1,1,2,1,2,2,1,1,…它的定义很简单,若把数列中相同的数
2017-08-15 18:57:10 215
原创 poj-1631-Bridging signals-最长上升序列(LIS)
额(⊙o⊙)… 先放题目链接题目传送门:https://vjudge.net/problem/POJ-1631题目就是求最长上升序列(自己想想吧!)
2017-08-14 10:55:38 266 2
原创 51node-1006-最长公共子序列Lcs
题目传送门:https://vjudge.net/problem/51Nod-1006dp的经典之一:用如下定义试试看:#include #include #include #include #include #include #include #include #include #define N 1005
2017-08-13 18:21:55 225
原创 hdu(poj)-2084(3176)-数塔-简单dp
题目传送门:https://vjudge.net/problem/HDU-2084好像没什么解释的 ^-^ 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5核心:dp[j] = mpa[i][j] + max(dp[j], dp[j + 1]);每次
2017-08-13 15:39:30 259
原创 lightoj-1134-Be Efficient
题目传送门:https://vjudge.net/problem/LightOJ-1134先思考一个问题:前缀和L与前缀和R对m取余之后余数相等,那么区间(L,R)与m有什么关系?例子:输 入: 1 2 3 4 5 6前 缀 和: 1 3 6 10 15 21
2017-08-13 15:07:46 256
原创 hdu-2602-Bone Collector-(0-1背包)
题目传送门:https://vjudge.net/problem/HDU-2602两种都可以for(i = n; i >= 1; i--){ for(j = 0; j { if(j dp[i][j] = dp[i + 1][j]; //第i个物品放入后,因为剩余空间不够无法放入。
2017-08-11 20:13:28 243
原创 uva-10815-Andy's First Dictionary-stl-set
题目传送门:https://vjudge.net/problem/UVA-10815主要是一些新的懂东西,(对于我一个开始学c的人来说)。不管什么,先上完整代码,再一一解释。#include #include #include #include using namespace std;set dit;int main(){
2017-07-31 08:44:22 300
原创 hdu-1213-How Many Tables
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1213并查集算法,推荐博客(点击“博客”两字)。#include #include#include#include#include#includeusing namespace std;int a[1005];int bing(int x){ i
2017-07-26 16:33:10 196
原创 poj-2718-Smallest Difference(dfs)
题目转送门:http://poj.org/problem?id=2718好激动尽然过了,调了好几个小时,一直超时,网上的代码,大部分为两种做法:一个是用next_permutation枚举全排列另一个是 dfs暴力枚举但是要注意一点,如果是下面的这种写法就会超时:#include #include #include #include
2017-07-25 14:01:21 268
原创 hdu-1372-Knight Moves(bfs和dfs)
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1372BFS:从起始点开始,每次对于满足题意的点,进行不满足题意的判断并且标记上该点的该次的计数(有时,可能为0或1,对于本题就是从起点走到次点的步数)。我们可以想象出一步一层的结构。为了完成这部分的操作,我们需要使用队列来完成,它每次的对于该层的判断,满足先进先出的原
2017-07-25 09:14:12 295
原创 poj-1979-Red and Black
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can'
2017-07-24 14:21:17 234
原创 hdu-1022-Train Problem I
As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over t
2017-07-21 17:28:25 301
原创 uva-514-Rails(栈)
There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to e
2017-07-21 17:24:21 216
原创 uva-10935-Throwing cards away I
队列#include using namespace std;int main(){ int n; while(cin>>n && n) { if(n==1) { cout<<"Discarded cards:"<<endl; cout<<"Remaining card: 1
2017-07-21 13:45:04 165
原创 堆栈的基本操作
queue 的基本操作有:queue q;入队,如例:q.push(x); 将x 接到队列的末端。出队,如例:q.pop(); 弹出队列的第一个元素,注意,并不会返回被弹出元素的值。访问队首元素,如例:q.front(),即最早被压入队列的元素。访问队尾元素,如例:q.back(),即最后被压入队列的元素。判断队列空,如例:q.empty(),当队列空时,返回tru
2017-07-21 11:12:45 3742
原创 zzuli-1858-单词翻转
#include using namespace std;int main(){ char str[150]; while(gets(str)) { int len=strlen(str); for(int i=0;i<len;) { if(!isalpha(str[i]))
2017-07-21 11:02:09 649
原创 hdu-1238-Substrings-c语言
SubstringsProblem DescriptionYou are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring
2017-03-07 19:41:27 292
原创 字符串的(暴力)枚举连续子串2
#includeint main(){ char str[4]="ABCD",a[4]; int i,j,k; for(i=0;i<4;i++) { for(j=i;j<4;j++) { for(k=i;k<=j;k++) { a[j-k]=str[k
2017-03-06 20:34:09 460
原创 字符串的(暴力)枚举连续子串1
#includeint main(){ char str[4]="ABCD",a[4]; int i,j,k; for(i=0;i<4;i++) { for(j=i;j<4;j++) { for(k=i;k<=j;k++) { a[k-i]=str[k
2017-03-06 20:14:04 922
原创 排序
选择排序/*运用递归的思想来进行排序。假设有n个数,用数组来存。one:找出1..n(位置)的最小数,然后将其放到最前端,1号位固定。two:找出2..n(位置)的最小数,然后将其放到2..n的前端,2号位固定。………………………………………………………………….一些运行下去,直到剩一个数字,结束。*/#includevoidselectsort
2017-03-05 20:42:58 249
codeblocks主题官方15个加自改5个
2018-01-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人