
Algorithm算法
hiyancy
small program program the world!
展开
-
LeetCode Largest Number JAVA 快速排序
题目链接:https://oj.leetcode.com/problems/largest-number/Code:public String largestNumber(int[] num) { Integer[] a = new Integer[num.length]; for(int i = 0; i < num.length; ++i) a[i] = num[i原创 2015-01-28 21:21:21 · 566 阅读 · 0 评论 -
POJ 2411 状态压缩DP
题目来源: http://poj.org/problem?id=2411题目大意:给一个h原创 2014-04-10 10:58:09 · 744 阅读 · 0 评论 -
HDU 3555 Bomb 简单数位DP
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=3555原创 2014-04-10 15:51:41 · 549 阅读 · 0 评论 -
NYOJ 435 棋盘覆盖(二)
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=435题目大意:在一个n*m原创 2014-04-10 19:05:00 · 612 阅读 · 0 评论 -
C++ StringBuilder 简易实现,多个对象共享同一内存
#pragma once#include <string.h>#include <stdlib.h>#include <string>class StringBuilder{public: const static int kDefaultSize = 64;public: StringBuilder() { init(); } Str原创 2017-08-24 14:58:06 · 810 阅读 · 0 评论 -
lua之屏蔽字替换为 '*'
local socket = require "socket"local function utf8len(ch) if not ch then return -1 end if ch < 0x80 then return 1 elseif ch < 0xC0 then return -1 elseif ch < 0xE0 then return 2 elseif原创 2017-06-15 10:37:57 · 982 阅读 · 0 评论 -
最小生成树(Kruskal算法)
畅通工程 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 27431 Accepted Submission(s): 12012 Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公原创 2017-02-16 16:04:20 · 296 阅读 · 0 评论 -
glibc的几个有用的处理二进制位的内置函数
— Built-in Function: int __builtin_ffs (unsigned int x)Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero.返回右起第一个‘1’的位置。— Built-in Function: int __转载 2017-02-08 10:02:29 · 319 阅读 · 0 评论 -
堆排序 hdu 1425 C++实现
#include #include using namespace std;const int N = 1000000;/** C++ 实现大顶堆 hdu 1425* >始终保持堆顶元素最大*/struct Heap { int sz; int a[N + 10]; Heap() { sz = 0; } void clear() { sz原创 2014-09-10 19:08:51 · 548 阅读 · 0 评论 -
HDU 4738 Caocao's Bridges
/*** Tarjan算法: 求桥* 时间复杂度: log(M+N)* 时间: 2014-08-23* 参考地址: http://www.cnblogs.com/frog112111/archive/2013/09/18/3329220.html* 题目大意: 无向边选出一条权值最小的边,使其连通分量增加**/#include #include #include原创 2014-08-23 11:14:10 · 458 阅读 · 0 评论 -
康拓展开 Test
#include using namespace std;typedef long long LL;/*** 康拓展开: X=an*(n-1)!+an-1*(n-2)!+...+ai*(i-1)!+...+a2*1!+a1*0!**/struct Cantor { int N; //数组的大小 LL *f; //阶乘数组 Cantor(int n = 9原创 2014-08-25 16:26:53 · 495 阅读 · 0 评论 -
SkipList时间复杂度分析O(log n)
SkipList作者: William Pugh论文: skiplists.pdf维基百科: Skip listSkipList,缘起leveldb源码,一见钟情。它是如此的简单,高效。又名跳跃表, 动态结构图如下(来自维基百科)。 图1SkipList由多层级单向有序链表组成。搜索,插入,删除的平均复杂度是O(logn)。so amazing! 接下来我们通过Pugh的论文一起来分析学习翻译 2017-09-29 09:14:46 · 6469 阅读 · 0 评论