
算法
immoshi
这个作者很懒,什么都没留下…
展开
-
《算法》实验一归并排序与快速排序 时间的比较
最近好多作业,好多实验呀。。算法先写出来,之后再完善一下原创 2014-04-16 13:41:28 · 1105 阅读 · 0 评论 -
【算法】二分答案法--暴力搜索答案方法
1,例子 浅谈二分答案2,解析 二分答案法、三分法3,原创 2018-03-03 15:42:19 · 1181 阅读 · 0 评论 -
LeetCode Median of Two Sorted Arrays 在两个已排列的数组中找出中位数。时间复杂度为O(log(min(N,M))
完成一道题,真的是好开心,虽然自己蠢蠢的,到了研究生还在弄这些基础的算法,才开始学去整理自己的知识。但是没关系,就算是要用几年的时间才能获得别人现在就拥有的知识能力,能就用几年的时间吧!题目:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorte原创 2017-04-05 16:12:02 · 10842 阅读 · 8 评论 -
zoj 1203 Swordfish prim算法
#include "stdio.h".#include #includeusing namespace std;double dis[105][105];double p[105][2];//点的坐标double ans;//最短距离int n;void makedis()//算出两个点之间的距离{ int i, j; double r; for (i = 0; i < n;原创 2014-04-20 22:59:58 · 839 阅读 · 0 评论 -
zju 1002
// zju 1002//#include "stdafx.h"#include #include using namespace std;int N = 4;int Max = 0;char a[5][5];int judge(int row, int col)//测试该坐标是否可以放置 返回 0 可放置,返回 1 不可放置{ for (int i = row - 1;原创 2014-04-05 16:08:48 · 952 阅读 · 0 评论 -
ACM2 递归 n分成k份
//将n 分成k份的 分法总数#include "stdafx.h"#include"stdio.h"#includeusing namespace std;int f(int n,int k){ if (k == 2) return n / 2; else { int s = 0; for (int i = 1; i <= n / k; i++)//第一份初始值i转载 2014-03-30 10:03:50 · 1571 阅读 · 0 评论 -
zoj 2833 friendship
这次真的很顺利了。。居然是因为ovr原创 2014-04-13 15:48:10 · 952 阅读 · 0 评论 -
zoj 1789 The Suspects
好高兴,又AC一道 ,不过是很类似的两道。。还是好高兴呀思想跟 183原创 2014-04-13 16:49:46 · 698 阅读 · 0 评论 -
zju 1091
// Traveling Knight Problem#include "stdafx.h"#include #include #include#include using namespace std;int a[8][8];//棋盘int MAP[8][2] = { { 2, 1 }, { 2, -1 }, { -2, 1 }, { -2, -1 }, { 1, 2 }, {原创 2014-04-05 11:26:26 · 773 阅读 · 0 评论 -
zoj 1204 Additive equations
set 作为参数要引用&!注意还原,调试非常好用!原创 2014-03-24 13:08:48 · 819 阅读 · 0 评论 -
zoj 1788 Quad Trees
zoj 1788原创 2014-05-10 09:17:15 · 1081 阅读 · 0 评论 -
ZOJ 2048 highways
#include "stdafx.h"#include #include #include #include #include "stdio.h"using namespace std;int town[750][2];double dis[750][750];double ans;int n;void prim(){ int temp[750]; //存放已经加入的结原创 2014-05-10 13:49:55 · 898 阅读 · 0 评论 -
1610
题目 点击打开链接用线段树的yy原创 2014-05-10 19:28:56 · 625 阅读 · 0 评论 -
红黑树总结
红黑树学习笔记红黑树的5个性质红黑树的插入红黑树的删除红黑树学习笔记红黑树的5个性质每个结点要么是红的,要么是黑的。 根结点是黑的。 每个叶结点(叶结点即指树尾端NIL指针或NULL结点)是黑的。 如果一个结点是红的,那么它的俩个儿子都是黑的。 对于任一结点而言,其到叶结点树尾端NIL指针的每一条路径都包含相同数目的黑结点。注意黑色的nil结点,对于红黑树的删除的理解很重要原创 2017-01-20 15:51:00 · 587 阅读 · 0 评论 -
2451
//这道 题似乎是默认一定会成功的,而且是按大小顺序输入的?//#include "stdafx.h"#include #include #define MAXN 100001#define MAX 500001struct node{ long x, y, w;} T[MAXN *2];long N, M, S, Va转载 2014-05-24 14:15:52 · 1000 阅读 · 0 评论 -
【算法】水坑 深信服笔试第一题
当时没有写出来,脑子完全懵逼状态。我恨我自己。求木板中间最大的容水量其实就一左一右两个指针,保存左高度maxleft,右边高度maxright,如果左的小,就向右移,因为此时右边肯定比左边的大,可以堵住水,如果当前的高度比maxleft小,则有坑,可以计算出此时可以装入的水(maxleft-height[i])。如果比maxleft大,则不能装入水,但要更新maxleft,maxleft和ma...原创 2018-09-22 21:54:09 · 1309 阅读 · 1 评论