自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 Semaphore 交替输出 ping pong

import java.util.concurrent.Semaphore;class Test extends Thread{ public static final int ITERATION = 10; public static Semaphore[] semas = new Semaphore[2]; private Semaphore[] m_semas = new Semap

2014-06-10 14:04:48 804

原创 python 2048 纯console

import randomdef printBoard(board,score): for line in board: #print " ".join(map(str,line)) def transform(x): if x == "0": return "_" else: return x print "%5s%5s%5s%5s" % tuple(

2014-05-18 11:35:22 4043

原创 c++ 函数对象动态规划解斐波那契数列

#include #include using namespace std;typedef long long int intLong;class Fib{ public: vector v; Fib() {v.push_back(0);v.push_back(1);} intLong operator() (intLong n) { if (v.size() >

2014-01-07 13:11:09 1041

原创 cpp study

#include #include #include #include #include #include #include using namespace std;class Point{ private: int x,y; public: Point(int x,int y):x(x),y(y){} double slopeTo(const Point& th

2014-01-06 18:57:00 3422

原创 二分图

class Graph: def __init__(self,n): self.n = n self.v = [[] for i in range(n)] def addEdge(self,a,b): self.v[a].append(b) def edges(self,a): return self.v[a]

2013-11-03 17:01:45 506

原创 Dragon Maze,python

def readMap(): m,n = [int(i) for i in stdin.readline().strip().split()] #print >> stderr,n enx,eny,exx,exy = [int(i) for i in stdin.readline().strip().split()] matrix = [] for i in

2013-10-12 16:48:27 520

原创 sudoku

def readSudoku(): c = int(stdin.readline()) sudoku = [] for i in range(c**2): sudoku.append([int(j) for j in stdin.readline().strip().split()]) return sudoku,cdef testLine(l

2013-10-12 10:18:10 523

原创 count inversion

def count(array): def merge(l,r): if len(l) == 0 or len(r) == 0: return (l+r,0) #print l,r n = 0 res = [] j,k = 0,0 lengthl = len(l)

2013-09-28 22:41:04 758

原创 kd树的java实现

public class KdTree { private int n; private Node root; private static final int LEFT = 1; private static final int RIGHT = 2; private static final int BOTTOM = 3; private static fin

2013-09-26 10:37:57 1735 1

原创 2013年google 在线笔试第五题被虐记。。

def memoize(f): def memf(*x): if x not in memf.cache: memf.cache[x] = f(*x) return memf.cache[x] memf.cache = {} return memfclass Graph: def __init__(self,

2013-09-24 18:41:48 473

原创 heap sort java

public class Sort { private static void sink(int[] a,int k,int N) { while (2 * k <= N) { int j = 2 * k; if (j < N && less(a,j,j+1)) j++; if (!less(a,k,j)) break; exch(a,k,j); k

2013-09-15 20:12:04 772

原创 三路快排 duplicate keys

def exch(l,i,j): temp = l[i] l[i] = l[j] l[j] = tempdef sort(l): quick(l,0,len(l) - 1)def quick(l,lo,hi): if lo >= hi: return v = l[0] i = lo gt = hi lt = lo

2013-09-14 16:06:31 470

原创 shell sort (python implementation)

def shellTest(l): h = 1 while h = 1: for i in range(h,len(l)): while i - h >= 0 and l[i] < l[i - h]: temp = l[i] l[i] = l[i - h] l[i - h] = temp i -= h h /= 3 return l

2013-09-09 08:53:39 412

原创 graph contraction algorithm

- -

2013-07-28 08:40:51 576

原创 快速排序 平均时间复杂度 分析(random pivot)

等啥会学会了再分析。。       - -

2013-07-21 12:15:30 1123

原创 快排 c

int choosePivot(int a[],int len){ int temp; temp = a[len - 1]; a[len - 1] = a[0]; a[0] = temp; return 0; }void quickSort(int a[],int len){ int pivot = 0; int i = 1,j,temp; int flag =

2013-07-16 09:45:43 828

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除