Skip to content

Instantly share code, notes, and snippets.

View hashplus's full-sized avatar
🇨🇳

p(^-^q) hashplus

🇨🇳
  • CN
View GitHub Profile
static int hash(int num, int k) {// k个不同元素的全排列的hash函数。s是K个元素的一个排列
int n[] = new int [k];
for (int i = k - 1 ; i >= 0; i--) {
n[i] = num % 10;
num /= 10;
}
int key = 0;
int c;
for (int i = 1 ; i < k; i++) {
class SortTask extends RecursiveAction {
final long[] array;
final int lo;
final int hi;
private int THRESHOLD = 30;
public SortTask(long[] array) {
this.array = array;
this.lo = 0;
this.hi = array.length - 1;
@hashplus
hashplus / heap
Created September 7, 2013 05:36
int heap[MAX_N],sz = 0;
void push(int x){
int i = sz++;
while(i>0){
int p = (i-1)/2;
if(heap[p] <= x)break;
heap[i] = heap[p];
i=p;
}
int L,P,N;
int A[MAX_N+1],B[MAX_N+1];
void solve(){
A[N] = L;
B[N] = 0;
N++;
priority_queue<int> que;
@hashplus
hashplus / hello-world.json
Created January 24, 2014 06:37
compser demo
{
"name":"acme/blog",
"repositories": [
{
"type":"composer",
"url":"http://packages.example.com"
},
{
"type":"composer",
@hashplus
hashplus / Syntax Highlighter.py
Created February 21, 2014 03:10
Sublime Syntax Hightlight
import sublime, sublime_plugin
import os, string, re
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Attempts to choose the correct syntax when more than one could apply. """
def __init__(self):
super(DetectFileTypeCommand, self).__init__()
self.path = None
// Original method
var object = {
method: function (x, y) {
return x+y;
}
}
// Add operations before or after!
object.method = (function (original) {
return function (x, y) {
@hashplus
hashplus / day1.js
Created April 16, 2014 08:25 — forked from auser/day1.js
angular.module('myApp.services', [])
.factory('UserFactory', function($http, $q) {
var service = {
// our factory definition
user: {},
setName: function(newName) {
service.user['name'] = newName;
},
setEmail: function(newEmail) {
service.user['email'] = newEmail;
function Player(name){
this.pointer = 0;
this.name = name;
}
Player.prototype.play = function(){
this.points +=1;
mediator.played();
};